Monday, December 29, 2008

Happy Birthday Andromeda

As you all know, the new year hype is building up everywhere and I am not an exception :)
I been bugging (not really Lol) my dad for the last two days to get me a laptop so that I can "network" it with my Desktop to practice for my RHCE examination. He was a little bit hesitating as I already have my cute, lovely, awesome and super fast "Fire Nooks" (yep! that's my desktop).

This was where my negotiation skills came into picture Lol I somehow made him finally agree (Don't ask me how, that's a top secret Lol) and this evening I bought one :) YAAY ME! It's an Acer Aspire 4730z

It looks cute, handy, comparitively cheaper and I am quite happy with it. The main part of it is, I have named it as "Andromeda". Guess why?

Well, I always had and still have a "thing" for space related stuff. Hence I chose Andromeda to be the name of this little cutie pie (my new born baby laptop Lol Now i know this is too much but that is what I am... kind of crazy).

If you are not aware what Andromeda is, it could be either of the below:

  • A constellation in the northern hemisphere between Cassiopeia and Pegasus; contains the Andromeda galaxy
  • As per Greek mythology an Ethiopian princess and daughter of Cassiopeia; she was fastened to a rock and exposed to a sea monster that was sent by Poseidon, but she was rescued by Perseus and became his wife
Here is the snapshot of what an Andromeda Galaxy look like:


You can use Google to know more about Andromeda, if you are interested.

Anyways, I am installing RHEL 5 in my Andromeda now... See you all later mates.

Keep smiling; let others wonder what you are upto :)

I recently was gaining some in-depth knowledge on the network security side and hence I though I would share what I have learnt from all over the web. In this article, we will discuss about Port Scanning. Before we dive directly into Port Scanning, there sure must be a lot of readers wondering what the heck is a port first of all? No worries! We are going to discuss everything in detail.

What is a Port?

A Port can be defined from three different perspectives:

1. The term Port as a noun:

a) When it comes to Computer and telecommunication devices, a port is generally a specific place for being physically connected to some other device, usually with a socket and plug of some kind. You must have heard of the terminologies like Serial Port, USB Port, etc yeah? It exactly the same thing.

b) In case of Programming, a port (noun) is a "logical connection place" and specifically, using the Internet's protocol, TCP/IP, the way a client program specifies a particular server program on a computer in a network. To say in easy terms, when you are under a proxy server, you have something like a Port: 80 in your browser's Internet Settings, yeah? That is it and now you know why we call it as a 'Logical Connection Place'.

2. The term Port as a verb:

In the world of programming, the term port is also used as a verb. i.e., to move an application program from an operating system environment in which it was developed to another operating system environment so it can be run there. If you are or were in the IT Industry, you sure must have heard about porting projects. To quote one example from my own experience, there a project where we "ported" few of the features that were already there in a product A (which we already developed), to a new product B (which we were developing). simply, it is the concept of moving the feature from something already exists to a new one.

Now that we are clear about the term PORT, let's move on to the concept of Port scanning.

The term PORT in Port Scanning means the case 1 b) which we discussed above and hence we will concentrate more on the word PORT as how it is defined in 1 b). Hence, from now on if I ever say PORT down the line of this article, understand that I am referring it as how I defined in 1 b).

With that mindset, let me tell you that...

There Port number ranges from 0 through 65535 and they are divided into three ranges: the Well Known Ports, the Registered Ports, and the Dynamic and(/or) Private Ports.

The Well Known Ports are those from 0 through 1023.
The Registered Ports are those from 1024 through 49151
The Dynamic and/or Private Ports are those from 49152 through 65535

Well Known and Registered Ports are intended for use by server applications that desire a default contact point on a system. On most systems, Well Known Ports can only be used by system (or root) processes or by programs executed by privileged users, while Registered Ports can be used by ordinary user processes or programs executed by ordinary users. Dynamic and/or Private Ports are intended for temporary use, including client-side ports, out-of-band negotiated ports, and application testing prior to registration of a dedicated port.

Check out the List of TCP and UDP Port Numbers when you have some time.

Various states of a Port:

A port can fall under either of the below three states:

Open
A service process is listening at the port. The OS (Operating System) receives packets arriving at this port and gives the messages to the service process. If the OS receives a SYN at an open port, this is the first packet of the three way handshake. (Note: The SYN we speak about here is NOT the progressive rock band of 2004 Lol You will get to know more about them if you are aware of the TCP Header structure but for now just understand that the SYN and RST we are discussing here are the Synchronize sequence numbers and Reset the connection respectively.)

Closed
No process is listening at the port. If the OS receives a SYN at a closed port, an RST is sent.

Filtered
A packet filter is listening at the port

Each of these available ports (0 through 65535) are like the doors through which a hacker could gain control over your system and it so essential that you keep them doors locked. This is when Port Scanning comes into picture.

What is Port Scanning and Why is Port Scanning needed?

It is similar to a thief going through your neighborhood and checking every door and window on each house to see which ones are open and which ones are locked. Simply put, attackers wish to discover services they can break into. Port Scanning is a technique used by hackers on the Internet to discover open network ports in your computer which they can break into. Network ports are communication channels for services such as email, telnet, file transfer, HTTP, etc. Since a port is where information goes in and out of a computer, port scanning identifies open doors to a computer, and if a port is open, it could be exploited by the attacker by breaking through the vulnerabilities (bugs) in the computer system. For example, in sending email, spammers try to relay their spam through an SMTP server which has an open port for them to come in and send the spam through it.

As you know, TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are two of the protocols that make up the TCP/IP protocol suite which is used universally to communicate on the Internet.

As we discussed already, the first 1024 TCP ports are called the Well-Known Ports and are associated with standard services such as FTP, HTTP, SMTP or DNS. Some of the addresses over 1023 also have commonly associated services, but the majority of these ports are not associated with any service and are available for a program or application to use to communicate on.

Port scanning software, in its most basic state, simply sends out a request to connect to the target computer on each port sequentially and makes a note of which ports responded or seem open to more in-depth probing.

If the port scan is being done with malicious intent, the intruder would generally prefer to go undetected. Network security applications can be configured to alert administrators if they detect connection requests across a broad range of ports from a single host. To get around this the intruder can do the port scan in strobe or stealth mode. Strobing limits the ports to a smaller target set rather than blanket scanning all 65536 ports. Stealth scanning uses techniques such as slowing the scan. By scanning the ports over a much longer period of time you reduce the chance that the target will trigger an alert.

There are a number of different methods to perform the actual port scans as well as tricks to hide the true source of port scan. You can read more about some of these by visiting these web sites: Port Scanning or Network Probes Explained.

It is possible to monitor your network for port scans. The trick, as with most things in information security, is to find the right balance between network performance and network safety. To help ensure that your network is protected and secure you may wish to perform your own port scans. An important thing here is to ensure you have the approval of all the powers that be before embarking on this project lest you find yourself on the wrong side of the law. To get accurate results it may be best to perform the port scan from a remote location using non-company equipment and a different ISP. Using software such as NMap you can scan a range of IP addresses and ports and find out what an attacker would see if they were to port scan your network. NMap in particular allows you to control almost every aspect of the scan and perform various types of port scans to fit your needs.

Technically, there is no way to stop someone from port scanning your computer while you are on the Internet. It is because in accessing any Internet service, your computer would open a port to Internet. There are, however, some things you can do to stay vigilant:

How to stay secured from Port Scanning attacks?

Once you find out what ports respond as being open by port scanning your own network you can begin to work on determining whether its actually necessary for those ports to be accessible from outside your network. If they're not necessary you should shut them down or block them. If they are necessary, you can begin to research what sorts of vulnerabilities and exploits your network is open to by having these ports accessible and work to apply the appropriate patches or mitigation to protect your network as much as possible.

  • To say in layman terms, Install an anti-virus software on your computers and remember to update the virus definitions and scan your PC for virus regularly (if possible, daily).
  • Install a firewall software to monitor for any scanning activities on your PC
  • Perform Windows Update - Microsoft will put out patches that will close up these open ports or fix other vulnerabilities when they are found. By performing Windows Update regularly, you can minimise the chances of your open ports being exploited. (Click the IE browser's menu Tools -> Windows Update -> Scan for Updates -> install all critical updates.)
  • Also, keep a eye on Updated and Latest Network Critical Security Alerts.

No one can deny the fact, If you are talented enough to stay secured, Hackers are more talented to find a way to break the security. However, taking preventive measures and staying secured does not hurt.

I have also read about the various types of Port Scanning and I shall share it with you all in an other article real soon.

Sunday, December 28, 2008

Hiding Files inside a Picture

Have you ever wondered if it is possible to hide your important files (may be PDF, EXE. TXT, or whatever) inside a photo? Here in this tutorial, we will see how to do it.

Step 1:

Get a photo or some picture and the files you want to hide inside it. Here I have taken my favourite Avril's wallpaper to be the picture. A TXT and EXE are the files I am planning to hide inside Avril's picture. I have placed all these under C:\Tutorials folder. You may place where ever you want but put it all inside a single folder.


Step 2:

Use WinRAR and create a RAR file from the files to be hidden (TXT and EXE files, here in my case).


PS: You may try WinZip but I have heard people saying it gives problem at times when you try to unzip them later down the line. WinRAR is free and more sophisticated so why not try WinRAR over WinZip.

Step 3:

Here comes the "trick" part. Goto command line (by Start->Run->Type cmd) and do what is shown below:


Note: The /b option with copy command is used to copy binary files. Applies to the filename preceding it and to all following filenames. Copied files will be read by size (according to the number of bytes indicated in the file`s directory listing). An end-of-file mark is not placed at the end of the copied file.

Step 4:

Now you have the FinalResult.JPG and this is the image that contains the rest of our TXT and EXE files in it.


Can't believe that this FinalResult.JPG has the hidden files in it? Okay let's do a confirmatory test.

Try renaming the FinalResult.JPG to FinalResult.RAR and Extract the content of FinalResult.RAR. Voila! You can see the TXT and EXE files, Yeah?
Alright, now rename the FinalResult.RAR back to FinalResult.JPG, Avril is back again :)

Simple trick yet comes handy in a lot of situations.

Unkn0wn.ws is one of the popular security sites with a handful of talented programmers and hackers. I am so surprised to see it got hacked yesterday. Well, I noticed it just by yesterday and so I am not sure since when it was hacked.

This is the message they have left for the site admin people.


Agree it or not, it really takes some extra talent to become a hacker! Do never mess with them, if you believe you can not compete them.

I have been facing some problems with my feed service. I do not want to blame anyone as I am the cause for it and I neither deny nor regret it.

I do not want to go on re-typing what mistake I did and how I am trying to fix it up. You can check Google Groups to know more on it, if interested.

My only request for now is, do NOT subscribe to my blog for now as I am in the process of fixing it up. Once done, I shall enable the Subscription form :)

I can't wait to have you back my Googlie-Wooglie subscribers Lol Take care till then.

Saturday, December 27, 2008

Lady GaGa

It has been almost two weeks since I checked out the latest music list. I forced myself the day before yesterday to take some time off my schedule and listen to what's new on the Pop block! I am not sure if I am too late in talking about Lady Gaga, but it is better late than never hey :)

Just to brief on Lady Gaga, her real name is Stefanie and she is just 22 years (She is younger than me and became a popular singer already... Shame I know Lol). I heard her "Just Dance" track on radio and got completely excited to check her album out. I then got myself a copy of her, "The Fame". I should admit, this album totally rocks! I personally liked the tracks

Just Dance - An amazing song loved by anyone who absolutely adores catchy dance/pop. Like everyone else say, it is an outrageously contagious, “easily-stuck-in-your-head” pop track.
Beautiful Dirty Rich - It is more like an industrial dance track. I liked it :)
Money Honey, Boys Boys Boys, Love Game and... Stop me someone or I sure am gonna list all the tracks Lol

To be honest, this is one great album I heard after quite a long time. I would suggest any of you dance/pop lovers to get yourself a copy if you don't have one already.

To say a few little interesting facts about Lady Gaga,

A New York girl from the start, Lady GaGa learned piano by ear at the age of four and, by age 13, had started writing music. She composed a piano ballad and was performing by age 14. At 17, young GaGa gained early admission to the Tisch School of the Arts at NYU and studied music. By 20, she was penning songs for Interscope artists like the Pussycat Dolls.
Bless the Lady Gaga!

I already have decided that I should post some articles on Unix/Linux. As I was wondering what and where shall I start from, I decided to start my posting from Introducing what Unix is. There really are a bunch of tutorials over the Internet to know about Unix, I am not denying the fact. This however is my way of writing what I learnt from others and other resources. That makes me happy :)

Okay, now enough with the stories, let's get down to the work straight away...


UNIX - as an Operating System

Unix is an operating system rather a specification. As many of you might be thinking, UNIX (pronounced YEW-nihks) is NOT an acronym. Unix is said to be a pun of Multics. Wondering what a Multics is? Well, Multics is a large multi-user operating system developed at Bell Labs shortly before Unix was created in the early '70s. (Brian Kernighan is credited with the name).

UNIX - as a Specification

Unix became the first open or standard operating system that could be improved or enhanced by anyone. A composite of the C language and shell (user command) interfaces from different versions of Unix were standardized under the auspices of the IEEE as the Portable Operating System Interface (POSIX). In turn, the POSIX interfaces were specified in the X/Open Programming Guide. These interfaces are also known as the "Single UNIX Specification" (SUS). The trademarked "UNIX" is now owned by the Open Group, an industry standards organization, which certifies and brands Unix implementations.

Brief History on Unix:

I did really not wanted to explain the History of Unix as there already are awesome links. I would suggest you to go through the below links to know more about the History of Unix.

A very brief look at Unix history
Levenez’s UNIX History
Unix History and Timeline from Unix.Org
A Brief History of Unix by Charles Severance

These links will recite you enough story about the History of Unix. If you still are striving for more, feel free to Google!

The Unix Impact:

Unix had real significant impact on the other Operating systems. Unix made the fact, "Assembly Language is necessary for systems implementation (on early computers)" a myth as Unix was written in high level language. Unix had drastically simplified file model compared to many contemporary operating systems. Yeah, everything in Unix is treated like a file, as simple byte arrays. The file system hierarchy contained machine services and devices (such as printers, terminals, or disk drives), providing a uniform interface. Unix is a stable, multi-user, multi-tasking system for servers, desktops and laptops. One fact about Unix is that it has less downtime, but has a higher learning curve

Unix Advantages

  • Unix is a real multitasking OS. Multiple users can run multiple programs each at the same time without interfering with each other or crashing the system. Isn't that cool?
  • The way how virtual memory is handled in Unix is very efficient and hence numerous numbers of programs can run with a decent amount of physical memory.
  • The security and access controls are handled in the best manner ever when compared to the competing Operating systems.
  • Unix has a powerful and unique file system. Like I said earlier, Everything is a file. Let it be a data, programs, or even all those physical devices, they all are considered as a file. Entire file system appears as a single large tree of nested directories regardless of how many different physical devices (disks) are included.
  • A lean kernel that gives you complete freedom - Yeah Unix kernel does the basics for you but doesn't get in the way when you try to do the unusual.
  • Unix is one Portable OS i.e., it's available on a wide variety of machines.
  • Optimized for program development, and thus for the unusual circumstances that are the rule in research.
Unix Disadvantages

All the Unix beginners complaint about are the below:
  • It's hard to install - I am telling you, it really is not that hard until you learn it. Unix does not follow the "I AGREE->NEXT->NEXT->FINISH" kind of process. Learn to get the hang of it. I know you can :)
  • I hate this terminal thingy - Why even try it if you hate it that much. The traditional command line shell interface (CLI) is not for the ones that are so used to the GUI environment. The CLI (or terminal) is designed for the programmer, not the casual user. Unix has it's own GUI, use it and quit complaining Lol

Various Unix flavors:

As you know (pardon me, if you don’t Lol), Unix is not a single operating system. It has many flavors i.e., variants, types, or you can even say it as implementations. Even though, it is based on a core set of Unix commands, different flavors have their own additional unique commands and features, and designed to work with different types of hardware. To be honest, no one knows exactly how many Unix flavors are there, but it is safe to say that if including all those that are obscure and obsolete, the number of Unix flavors is at least in the hundreds. You can often tell that an operating system is in the Unix family if it has a name that is a combination of the letters U, I, and X.

To mention a few, AIX by IBM, Solaris by Sun Microsystems. If you are so eager to know more, check the Unix Flavors Page

Also, go through 2008 Server OS Reliability Survey at leisure. Worth a read!

Thursday, December 25, 2008

Shutting Down Xp In Different Ways

I really am not sure if are aware of the various ways to shut down your Windows XP computer. I just thought I would share a few. Feel free to add if I left any.

  1. The standard approach - Click the Start Button with your mouse (obvious eh?), then select the Turn Off menu and finally click the Turn Off icon on the Turn Off computer dialog.
  2. Press CTRL+ESC key or the Win key and press u two times - the fastest approach.
  3. Get the Shutdown utility from download.com - It add the shut down shortcuts for you. Else create them yourself using approach 4 (the one mentioned below).
  4. Create a shutdown shortcut on your desktop by a Right click on the desktop, choose New Shortcut and type shutdown -s -t 00 in the area where you are asked to specify the location of the program file. Now you can just double click this icon to turn off the computer. The best location would be your quick launch bar.
  5. Press the WIN key + R key to open the run window. Type shutdown -s -t 00. [s means shutdown while t means the duration after which you want to initiate the shutdown process].If some open processes or application won't let you turn off, append a -f switch to force a shut down by closing all active processes.
  6. WIN key+M to minimize all windows and then ALT+F4 to bring the Turn Off computer dialog.
  7. Open Windows Task manager (by right clicking the Windows Task bar or ALT+CTRL+DEL) and choose Shut down from the menu. Useful when the Windows are not responding.
  8. Open Task Manager, Click on the Shutdown menu, hold the CTRL key and Click on Turn-Off. Your PC will be turned off in 3 secs. This is the fastest method than hard shutdown.
Which one do you think you are going to use then? :)

As the heading of this post clearly states, Overloading and Overriding have got not even a darn thing in common to be spoken together in any context. Beginners often tend to get confused between these two totally different terminologies, may be because they rhyme so well. Anyways, we will be discussing about these two jargons today.

Do you know what does a Function Signature consist of?

A function's signature consists of the number and type of its declared arguments (otherwise known as "formal" arguments). Consider the function definition,

void function1(int,int);

This statement says, function1 is a function taking two integer arguments and returning nothing (void return type).

Now that you are aware of function signatures, let’s move on with the Overloading concept…

Overloading occurs when two or more functions in the same scope have the same name and different signatures. When the compiler looks up a function name and finds more than one function with that name in a scope, it selects among the available candidates in that scope for the one whose formal arguments best match the actual arguments of the function call. This is what called as “Overloading”.

Overriding occurs in case of Polymorphism i.e, when a derived class function has the same name and signature as a base class virtual function. In such cases, whenever a virtual call to a derived object occurs, the implementation of the derived class function will replace that of the inherited base class function. Basically, Overriding changes the behavior of a class but not its interface.

Consider the following simple base class:
class base {
public:
//...
int fn( int );
void fn( float );
//...
};

In this example, the function fn is overloaded in the class base because two different functions named fn are with in the same scope.

To squeeze in the concept of Overriding, let’s consider the below code…


class base {
public:
//...
virtual int fn( int );
void fn( float );
//...
};

class derived : public base {
public:
int fn( int );
int fn( float );
};

The member function derived::fn(int) overrides the base class virtual function base::fn(int). The member function derived::fn(float) doesn't override anything, because base::fn(float) is not virtual. It does, however, overload derived::fn(int). Note that it does not overload the base class member base::fn, because it's in a different scope.

Variation:

Is it not necessary to use the keyword virtual in the derived class’ fn function?

The member function derived::fn(int) overrides the base class’ fn function and so it is defined virtual in the base class; the use of the keyword virtual in the derived class is completely optional and has no effect on the meaning of the program. A common misassumption is that omitting the virtual keyword in the derived class will prevent further overriding in more derived classes. This is not the case.

Wednesday, December 24, 2008

Useful .bat files

If in case you do not know what a .bat file is, I suggest you to read Batch Files before proceeding any further.

Are you back? Okay, that was real quick :)

I am not going to take any effort in explaining in any of the below batch files. Why don't you just Google it and learn, if you are that eager? Lol Not that I am too lazy to explain you but I really want you to get to know them all by yourself for you might even end up writing your own batch file then. Fair enough?

Alright! With no further lecture, here I present you the batch files:

How to use:

  1. Copy and paste the codes in an empty notepad. Give them any name you want to but save them with .bat extension for them to become a batch file.
  2. Double on the .bat file to execute it.

Quick Clean:

@echo off
echo starting ......
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\local settings\temporary internet files\*.*"
del /f /s /q "%userprofile%\local settings\temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
echo ok!
echo. & pause

Cookies Cleaner:

cd %userprofile%
%homedrive%
del cookies\*.* /f /s /q

index.dat Cleaner:

Wondering what a index.dat is? Read more on index.dat if you want to.

@echo off
del "%homedrive%\documents and settings\default user\cookies\index.dat"
del "%homedrive%\documents and settings\default user\local

settings\history\history.ie5\index.dat"
del "%homedrive%\documents and settings\default user\local settings\temporary internet

files\content.ie5\index.dat"
del "%userprofile%\cookies\index.dat"
del "%userprofile%\local settings\history\history.ie5\index.dat"
del "%userprofile%\local settings\history\history.ie5\mshist012006032820060 329\index.dat"
del "%userprofile%\local settings\history\history.ie5\mshist012006032920060 330\index.dat"
del "%userprofile%\local settings\temporary internet files\content.ie5\index.dat"
del "%userprofile%\userdata\index.dat"
del "%homedrive%\documents and settings\localservice\cookies\index.dat"
del "%homedrive%\documents and settings\localservice\local settings\history\history.ie5\index.dat"
del "%homedrive%\documents and settings\localservice\local settings\temporary internet

files\content.ie5\index.dat"
del "%windir%\system32\config\systemprofile\local settings\history\history.ie5\index.dat"
del "%windir%\system32\config\systemprofile\local

settings\history\history.ie5\mshist012006032320060 324\index.dat"
del "%windir%\system32\config\systemprofile\local settings\temporary internet

files\content.ie5\index.dat"

Disable ctfmon.exe from running:

Read more on ctfmon.exe if you want to.

@echo off
regsvr32.exe /u msimtf.dll
regsvr32.exe /u msctf.dll

Before we answer this question, let us get back to some basics.

As you know, pointers is there both in C and C++ where as References is something that does not exist in C but in C++. It’s very common to see beginner level developers often getting confused with these two terminologies. There are a few who even argue references and pointers are one and the same. If you are one of those, let’s get this straight right now…

References and Pointers are two different concepts. Reference is an alias where as Pointer is a variable which holds the address of another variable. C++ compilers often implement references as pointers, but believe me they are not pointers and do not behave like pointers either.
Ideally, a Reference is another name for an existing object. Once a reference is initialized with an object, you can either use the object name or the reference name to refer to the object.

Consider the below example:

int aVar = 12;
int &aVarzAKA = aVar; // aVarzAKA is another name for aVar
--aVarzAKA; // aVar == 11
aVar = 10; // aVarzAKA == 10
int *aPtrVar = & aVarzAKA; // aPtrVar points to aVar


Now back to the question, “Are null references allowed in C++?

References can NOT be null where as a Pointer can be null (you know about Null Pointers, Don’t you? If not, we surely will talk about it later sometime.).

Never forget that all References need initialization and a Reference always refers to the object with which it was initialized. In the example quoted above, the reference aVarzAKA will refer to aVar for its entire lifetime.

Just because I say there are NO null references, you really need not believe me. You very well can question me what if I attempt to make a reference null?

Okay, let’s try and see what happens now…

Test &myTest = *static_cast(0); // Compiler Error

The above statement throws a compile time error. However, there are cases when the compiler may not detect if you create a null reference. During such less obvious attempts, even though the compiler is not complaining, it will cause undefined behavior at run-time. For example,


Test *startTest();
//...
Test &myTest = * startTest(); // this probably is a bad code
if( &myTest == 0 ) // Results in undefined behavior


Observe the above code for a while. What if startTest() returns a null pointer?
Disaster! Yeah, the behavior of this code is undefined then. A better solution would be to use a pointer to hold the result of startTest as shown below:

Test *ptrTest = startTest();
if( ptrTest )
{
// Implementation goes here
}

Hence, the requirement that a reference must be initialized implies that the object to which it refers must be in existence when the reference is initialized. A reference is an alias for an object that already exists prior to the initialization of the reference. Once a reference is initialized to refer to a particular object, it cannot later be made to refer to a different object; a reference is bound to its initializer for its whole lifetime. In effect, after initialization a reference disappears and is simply another name for its initializer thereafter.

Variations:

1. Initializing References to non-constants

A reference to a non-const cannot be initialized with a literal or temporary value. The below both snippets result in compilation error:
double &d = 12.3; // Compiler Error
someFunction( std::string("Hello"), std::string(", World") ); // Error

2. Initializing References to constants

In case of references to constants,

const double &d = 12.3; // Allowed
template
T sum( const T &a, const T &b ) {
return a + b;
}
//...
const std::string &greeting
= sum(std::string("Hello"),std::string(", World")); // Allowed

When a reference to const is initialized with a literal, the reference is set to refer to a temporary location that is initialized with the literal. Therefore, d does not actually refer to the literal 12.3 but to a temporary location of type double that has been initialized with 12.3. Also, the reference greeting refers to the unnamed temporary string return value of the call to sum.
Remember that, such temporaries are destroyed (that is, go out of scope and have their destructors called) at the end of the expression in which they're created. However, when such a temporary is used to initialize a reference to const, the temporary will exist as long as the reference that refers to it.

*** This tutorial is for beginners and not for any advanced users.

There are a lot of cases with Windows XP where you would want to edit the registry entries. Every time before you edit the registry, you are advised to take a back up of your registry. You never know what you are going to end up with. You may either export the keys in the registry that you plan to edit, or back up the whole registry. If a problem occurs, you can then follow the steps how-to restore the registry to its previous state.


How to Export Registry Keys

  1. Click Start, and then click Run.
  2. In the Open box, type regedit, and then click OK.
  3. On the File menu, click Export. The Export Registry File window appears as shown.
  4. At the bottom of Export Registry File window, you will see two radio buttons under 'Export Range'. Select either of the choices according as to whether you want to export all or only selected branches of the registry.
  5. Now select a location in which to save the backup .reg file. In the File name box, type a file name, and then click Save.



How to Restore the Registry


To restore registry keys that you exported, double-click the .reg file that you saved.

Tuesday, December 23, 2008

Modify START button text

Are you bored of the very same start text on the start button? Do you feel like trying out various texts on it like Begin, Commence, Initiate, etc? You need to read this tutorial then!

To achieve this, we will be modifying an itsy-bitsy of two files namely:

  1. explorer.exe under C:\Windows folder
  2. An entry in our registry
We can not start directly altering explorer.exe for it is an executable file. Since explorer.exe is a binary file it requires a special editor. There are many such special editors available over the Net but I prefer using Resource Hacker. If in case you are interested, Resource Hacker is a freeware utility to view, modify, rename, add, delete and extract resources in 32bit Windows executable and resource files (*.res). It incorporates an internal resource script compiler and decompiler and works on Microsoft Windows 95/98/ME, Windows NT, Windows 2000 and Windows XP operating systems.

Download Resource Hacker from http://www.angusj.com/resourcehacker/

Step 1 - Modify the text in String Table

The first step is to make a backup copy of the file explorer.exe located at C:\Windows\explorer. Place it in a folder somewhere on your hard drive where it will be safe. Start Resource Hacker and open explorer.exe located at C:\Windows\explorer.exe.

The category we are going to be using is "String Table". Expand it by clicking the plus sign then navigate down to and expand string 37 followed by highlighting 1033. If you are using the Classic Layout rather than the XP Layout, use number 38. The right hand pane will display the string table. We’re going to modify item 578, currently showing the word “start” just as it displays on the current Start button.

There is no magic here. Just double click on the word “start” so that it’s highlighted, making sure the quotation marks are not part of the highlight. They need to remain in place, surrounding the new text that you’ll type. Go ahead and type your new entry. In my case I used Touch Me! [No No Nothing titillating ;)]

You’ll notice that after the new text string has been entered the Compile Script button that was grayed out is now active. I won’t get into what’s involved in compiling a script, but suffice it to say it’s going to make this exercise worthwhile. Click Compile Script and then save the altered file using the Save As command on the File Menu. Do not use the Save command – Make sure to use the Save As command and choose a name for the file. Save the newly named file to C:\Windows.


Step 2 – Modify the Registry Entry

*** make a backup of your registry before making changes ***

Now that the modified explorer.exe has been created it’s necessary to modify the registry so the file will be recognized when the user logs on to the system. Modifying registry entries could cause loss big time but for this tutorial we are not going to do any massive change so you are all set as long as you follow what I say. Go to Start (soon to be something else), Choose Run and type regedit in the Open field. Navigate to:

HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows NT\ CurrentVersion\ Winlogon

In the right pane, double click the "Shell" entry to open the Edit String dialog box. In Value data: line, enter the name that was used to save the modified explorer.exe file. Click OK.

Close Registry Editor and either log off the system and log back in, or reboot the entire system if that’s your preference. If all went as planned you should see your new Start button with the revised text.

There are a bunch of real time situations where most of us will not know whether to use 'WERE' or 'WAS'. Just to quote one for example, Let us consider Beyonce's latest hit song, "If I WERE a boy even just for a day...". Why could it not be "If I WAS a boy even just for a day..."?

It is said that "WERE" is used for plural (more than one) subjects and "WAS" should be used for singular subjects. I being a singular subject, why 'WERE' is being used then?

This is where the Subjunctive Mood comes in to picture. That is, using WERE for singular subjects is grammatically termed as 'Subjunctive Mood' (sometimes referred to as the conjunctive mood, as it often follows a conjunction). This mood is used to express a wish or possible situation that is currently not true. It's usually used with words like "if" and "wish".

As per the English Grammar rule is, "In the subjunctive mood the plural form WERE should be used with a singular subject; as, If I WERE, not WAS." For one's easy understanding we can say, "A person would use WERE when expressing feelings in cases which are not true"

In FORMAL writing, use WERE rather than WAS to express a state of affairs that is contrary to the facts:
I wish it WERE finished (but it is not).
Suppose it WERE true (but it is false).

Similarly for hypothetical conditions after if:
If John WERE here, he would know.
If it WERE to rain we should get wet.
He spoke as if I WERE deaf.

In all of the above, WAS is common in less formal styles. But even when you are not attempting formality, WERE is the only choice in inverted sentences like WERE these true, it would be very alarming.

From now on what ever you want to be, wish that you WERE a … and not you WAS a …

Monday, December 22, 2008

Tricky If Statement

Question:

Carefully go through the below snippet. I want the below program to print "Hello World".
Sit back, think for a while and try to find out what that "X" can be replaced with to get the desired output.

if (X)
{
printf ("Hello");
}
else
{
printf("World");

Solution:

Awesome, if you have found the answer already. If not, here is the answer for you...

!printf("Hello")

So the snippet should have been:

if (!printf("Hello")) // Hello is printed by this statement
{
printf ("Hello"); //This statement never gets executed
}
else
{
printf("World"); //World is printed by this statement


Explanation:

Before I start with the explanation, I would like to question you, "what does printf() return?" The clue lies in there! :)

Upon a successful return, the printf() function returns the number of characters printed (not including the trailing '\0' used to end output to strings). If the output was truncated due to this limit then the return value is the number of characters (not including the trailing '\0') which would have been written to the final string if enough space had been available. Thus, a return value of size or more means that the output was truncated. If an output error is encountered, a negative value is returned.

Thus, if(!printf("Hello")) does two things -
  1. Prints Hello
  2. Returns a non-zero value.

Notice the ! mark in-front of the printf() within the if condition. This makes the if condition fail and hence the else part gets executed which prints world resulting in the desired output:

Hello World

Variations:

With the explnation provided above, think what would the below line print out?

printf("%d",(printf("Hello")));

yeah, you got it right! The output will be:

Hello5

NOTE: 5 is the number of characters printed out by the "%d" of the outtermost printf() function. i.e., the total number of characters (in the string "hello") is printed out.

Let's try one more now...

Find the output -

int i=448; printf("%d\n",printf("%d",printf("%d",i)));

The output is -

44831

How??


The innermost printf("%d", i) prints 448 which is nothing but the value of variable i.
Hence the statement printf("%d",printf("%d",i)) will result in 4483 (here 3 is total number of characters/numbers the innermost printf printed out which is nothing but 448). The total number of characters/numbers the recent printf out printed out is 1 (remember?? the recent printf printed out 3, i.e., a single digit number). Hence the outtermost printf prints out 1. This results in the final result 44831.

Simple, yet interesting, Isn't it? :)

System Restore rescues you when your Windows machine may go insane at times (Is it only at times???).

There even might be cases when a Windows system can’t even start up. In such case, try using the Safe Mode with Command Prompt to access System Restore. Follow the steps given below:

  1. After swtiching your computer on, press the F8 key several times ('several times' yes, seriously I mean Lol) until the Windows Advanced Options Menu screen appears.
  2. Use the up or down arrows on your keyboard to select Safe Mode with Command Prompt, and then press Enter.
  3. The next screen displays the message, “Please select the operating system to start.” Assuming you only have Windows XP installed on your system, press Enter. If you have more than one operating system installed, use the up and down arrow keys to select Windows XP, and then press the Enter key.
  4. Windows loads some software, which could take a minute or two. Depending on how your version of Windows is configured, a login screen or the Welcome Screen appears. If you see the login screen, type your account name and password (if you have one), press Enter. If you see the Welcome Screen, click the icon for the account labeled Administrator or an account that has administrative privileges, and then type your password (if you have one).
  5. Next, a command prompt appears.Type %systemroot%\ system32\restore\rstrui.exe in the blank, and then press the Enter key.
  6. After several seconds, the System Restore window appears. Click the Restore My Computer to an Earlier Time button.
  7. Click the Next button, located near the lower-right corner of this window.
  8. A calendar appears. In it, click a day when your computer was working properly, and then click the Next button.
  9. To confirm your choice, click Next.
  10. The System Restore process begins. Moments later, your computer automatically restarts itself. When it boots up, follow the on-screen instructions.


If you are a Power User, you might often want to get rid of those unused files sitting unnecessarily in your system making your system slow down.

There are bunch of tools out there over the net which does this job but they are shareware like the Tune Up Utilities 2008, etc.

*** Don't bother reading further if you are a "warez" user *** LOL

If you do NOT want to cash out for such a tool, then I would suggest anyone to choose CCleaner for it is a

  • Freeware
  • Slim,
  • Clean and
  • Does a fantastic job

CCleaner is absolutely one of the greatest programs I'm running in my Windows XP SP2. It exactly does what it says and I have never experienced a

broken system due to the use of this software.

I do not want to persuade you :) Why not try CCleaner once for yourself? If in case it fails to satisfy you (which it definitely won't), you are not going to lose a penny anyways.

Download - http://www.ccleaner.com/download


As most of my mates know I had been with Wipro Technologies for the past four years and 3 months. I had to quit Wipro for certain reasons and hence I been trying for various opportunities outside since 3rd December 2008.

I attended almost four interviews out of which I got selected in three namely Zylog Systems, CTS, CSC. Verizon is the one where I could not make it through in the 3rd round. I however had my own learning from all the interviews :)

Out of all the Interviews, I personally found Logica's and CSC's to be very competitive. After 2 days discussion with family and mates, I had chosen Logica to be my company and today (22nd December 2008) I joined them.

This day at Logica was very cool. Nothing much to mention, honestly! I reached the campus at 8.50 AM sharp. There were 15 other people with me who were about to join Logica today. We all were taken by the HR team to a conference room where we filled up the application form, Signed up the offer letters blah blah... It's nothing really new Lol This process went from 9 AM till 11 AM.

We then were informed that we will be addressed by the On-Board committee team but unfortunately they could not make it before Lunch. We however waited till 12.30 PM chit-chatting about each other's previous experiences and a darn bit of personal life as well. By 12.30 PM we all moved for Lunch and got back to our seats by 1.55 PM sharp hoping we will be addressed by the On-board committee people. The respective people turned up by 2.45 PM and took us up to the 8th floor and presented us couple of videos and PDF documents to get to know more about the Company. For the experienced candidates, it's nothing new again, isn’t it? Lol There is the so called "process" anyways.

I then had been introduced to the project where I will be put into. I met the Technical Lead. He is not new to me as he was the one who interviewed me. I was supposing to meet my Delivery manager as well but I could not as he was busy and off his place for some official reasons. Then again, I already have seen him during my last round of Interview :)

Since then we were left free on our own till 4.30 PM. YAAY!! This one week time of lean period is the only time when any employee can stay as a free-bird with neither the project pressure nor the project manager's Lol

To summarize, this first day at Logica was a real wonderful experience in meeting up new people, having a soothing day, a new work culture, etc. I am so much excited about experiencing the work environment and other team members. We all have been informed that we will be having our Induction program by 3 PM tomorrow and I just can not wait to witness the happenings :)

I will mail all my mates once I get my Office E-Mail ID. Do stay in touch pals. I miss you all and it goes with out saying! Take care :)

I recently been going through a PC Magazine where I found these top 9 skills every nerd needs. This one is quite funny :)



I loved the 4th and 2nd one to the core. I always used Texpad for editing my HTML/XML/CSS files. Guess, it's time for me to switch over to Notepad Lol

And talking about the 2nd skill - Anyone can find North Haverbrook but finding Ogdenville takes serious nerd talent.

9. Explain what E = MC^2 is to a liberal arts major
8. Build a PC blindfolded
7. Calculate a Pitcher's earned run average
6. Know the question that 42 is the answer to
5. Recite PI to 23 decimal places
4. Code a webpage using Notepad
3. Differentiate between Dr.Pepper and Mr. Pibb
2. Locate Ogdenville on a Map
1. DEBATE - "the relative merits of a an Imperial star destroyer versus the USS Enterprise"

Sunday, December 21, 2008

Findind the System Uptime in Windows XP

How long has your system been running?

It surely depends on if the question is referring to your system at home or the one at office. As everyone knows, most of the IT Professionals are unfortunately habitual of leaving their system on for weeks or even months. Did it ring a bell?? Lol

Anyways, here we will see how to identify how long a system is running and this tutorial is specific to Windows XP.

Click Start -> Run and type cmd to open up a command prompt.
At the prompt, type systeminfo

Wait for a couple of seconds and scroll down the list of information to the line that says 'System Up Time'.

This will tell you in days, hours, minutes and seconds how long the system has been up.

Note: This command only works in XP Pro and not in XP Home. You can, however, type net statistics workstation at the prompt in Home. The first line will tell you the day and time that the system came online.

This sure is a pretty simple one but worth mentioning.

In order to view the hidden files using DOS Prompt, do the following:

Open up the command prompt and just type
dir /ah

If in case the list is too long then you can use
dir /ah/p/w

Friday, December 19, 2008

Find everything uploaded on Rapidshare

As you all might know, Rapidshare is a Premium File Hosting Service. Even though, it's time limit and download limit are annoying for the free users, the premium users benefit much out of it for it is one of the very few file hosting services with real decent download speed and with NO pop-ups.

I here would be explaining three very simple ways to find almost everything that is hosted (or "uploaded", to keep it simple) on Rapidshare.

Let's screw Rapidshare Lol

Find things uploaded On Rapidshare Using Google

Copy the following code and paste it on your Browser's address bar:

http://www.google.com/search?q=+.rar+OR+.zip+OR+.pdf+OR+.exe+site:rapidshare.com&hl=en&lr=&as_qdr=all&start=30&sa=N

This will give you links of all the files (of the format .rar OR .zip OR .pdf OR .exe) that are uploaded on Rapidshare.

Find Movies in particular

Let's say you don't really give a damn about the .rar or zipped files and you only want to find the movies that are uploaded on Rapidshare then copy the following code and paste it on your Browser's address bar

http://www.google.com/search?q=+.wmv+OR+.avi+OR+.3gp+OR+.mpeg+OR+.rm+site:rapidshare.com&hl=en&lr=&as_qdr=all&start=10&sa=N

This will give you the links of all the movies that are of format .wmv OR .avi OR .3gp OR .mpeg OR .rm

Note: The .3gp files will mostly (and not necessarily) be either MMS Clips or movies that are converted for viewing in Mobile Phones.

You can use this same logic for various other file formats and any specific file/movie/album as well. You might hit the gold if it already has been uploaded on Rapidshare. Replace the URL in codes to rapidshare.de from rapidshare.com if you want to find the files on rapidshare.de – Simple!

This is the manual way of searching for Rapidshare files. Obviously, there are many Rapidshare search engines over the net.
You very well can use them whereas this manual search is fun, isn’t it?