Wednesday, July 16, 2008

How to get to the command prompt by registry file add

Very frequently we need to create command prompt at a certain folder. Most users directly go to command prompt and then type out the entire pathname to get to the required folder.
Would it not be much easier to get to the command prompt by directly right-clicking on the folder?
Below is how you can do it. This is valid only for Win XP. Other operating systems have not been checked.

1. Create a text file wherever it is easy for you to access it.
2. Copy and past the following data into the file command.txt :

REGEDIT4
[HKEY_CLASSES_ROOT\Directory\shell\DosHere]
@="Command &Prompt Here"

[HKEY_CLASSES_ROOT\Directory\shell\DosHere\command]
@="C:\\Windows\\System32\\cmd.exe /k cd \"%1\""

[HKEY_CLASSES_ROOT\Drive\shell\DosHere]
@="Command &Prompt Here"

[HKEY_CLASSES_ROOT\Drive\shell\DosHere\command]
@="C:\\Windows\\System32\\cmd.exe /k cd \"%1\""

3. Save the file
4. Now rename the extension from a command.txt to a command.reg (registry type file). Go to DOS prompt and type C:\ren command.txt command.reg
5. Double clicking the file will pop up a dialog box saying "Are you sure you want to add the data to the registry".
6. Say yes and the data gets added into your windows registry.
7. Now any folder where you want a command prompt, it is as easy as right clicking on the folder and choosing "Command Prompt Here".

Simple as that....

Monday, July 7, 2008

Analyzing Core Dumps and Assert Debugging

#define ASSERT(x)
void assert(int expression);
If expression evaluates to 0 (false), then the expression, sourcecode filename, and line

number are sent to the standard error, and then calls the abort function.
Common error outputting is in the form:

Assertion failed: expression, file filename, line line-number

#define NDEBUG === > then the macro assert does nothing.

To enable core dumps for your current shell, use ulimit to set a maximal core dump size in megabytes.
For this example, we'll "limit" core dumps to 1 gigabyte:

gcc -g -o exe_name main.c
$ulimit -c 1024
$ls -als core

Analyzing Core Dumps
====================
$gdb ./exe_name ./core_filename

Thursday, July 3, 2008

Windows XP Commands ,Tips and Hacks

1. It boasts how long it can stay up. Whereas previous versions of Windows were coy about how long they went between boots, XP is positively proud of its stamina. Go to the Command Prompt in the Accessories menu from the All Programs start button option, and then type 'systeminfo'. The computer will produce a lot of useful info, including the uptime. If you want to keep these, type 'systeminfo > info.txt'. This creates a file called info.txt you can look at later with Notepad. (Professional Edition only).

2. You can delete files immediately, without having them move to the Recycle Bin first. Go to the Start menu, select Run... and type 'gpedit.msc'; then select User Configuration, Administrative Templates, Windows Components, Windows Explorer and find the Do not move deleted files to the Recycle Bin setting. Set it. Poking around in gpedit will reveal a great many interface and system options, but take care -- some may stop your computer behaving as you wish. (Professional Edition only).

3. You can lock your XP workstation with two clicks of the mouse. Create a new shortcut on your desktop using a right mouse click, and enter 'rundll32.exe user32.dll,LockWorkStation' in the location field. Give the shortcut a name you like. That's it -- just double click on it and your computer will be locked. And if that's not easy enough, Windows key + L will do the same.

4. XP hides some system software you might want to remove, such as Windows Messenger, but you can tickle it and make it disgorge everything. Using Notepad or Edit, edit the text file /windows/inf/sysoc.inf, search for the word 'hide' and remove it. You can then go to the Add or Remove Programs in the Control Panel, select Add/Remove Windows Components and there will be your prey, exposed and vulnerable.

5. For those skilled in the art of DOS batch files, XP has a number of interesting new commands. These include 'eventcreate' and 'eventtriggers' for creating and watching system events, 'typeperf' for monitoring performance of various subsystems, and 'schtasks' for handling scheduled tasks. As usual, typing the command name followed by /? will give a list of options -- they're all far too baroque to go into here.

6. XP has IP version 6 support -- the next generation of IP. Unfortunately this is more than your ISP has, so you can only experiment with this on your LAN. Type 'ipv6 install' into Run... (it's OK, it won't ruin your existing network setup) and then 'ipv6 /?' at the command line to find out more. If you don't know what IPv6 is, don't worry and don't bother.

7. You can at last get rid of tasks on the computer from the command line by using 'taskkill /pid' and the task number, or just 'tskill' and the process number. Find that out by typing 'tasklist', which will also tell you a lot about what's going on in your system.

8. XP will treat Zip files like folders, which is nice if you've got a fast machine. On slower machines, you can make XP leave zip files well alone by typing 'regsvr32 /u zipfldr.dll' at the command line. If you change your mind later, you can put things back as they were by typing 'regsvr32 zipfldr.dll'.

9. XP has ClearType -- Microsoft's anti-aliasing font display technology -- but doesn't have it enabled by default. It's well worth trying, especially if you were there for DOS and all those years of staring at a screen have given you the eyes of an astigmatic bat. To enable ClearType, right click on the desktop, select Properties, Appearance, Effects, select ClearType from the second drop-down menu and enable the selection. Expect best results on laptop displays. If you want to use ClearType on the Welcome login screen as well, set the registry entry HKEY_USERS/.DEFAULT/Control Panel/Desktop/FontSmoothingType to 2.

10. You can use Remote Assistance to help a friend who's using network address translation (NAT) on a home network, but not automatically. Get your pal to email you a Remote Assistance invitation and edit the file. Under the RCTICKET attribute will be a NAT IP address, like 192.168.1.10. Replace this with your chum's real IP address -- they can find this out by going to IPADDRESS -- and get them to make sure that they've got port 3389 open on their firewall and forwarded to the errant computer.

11. You can run a program as a different user without logging out and back in again. Right click the icon, select Run As... and enter the user name and password you want to use. This only applies for that run. The trick is particularly useful if you need to have administrative permissions to install a program, which many require. Note that you can have some fun by running programs multiple times on the same system as different users, but this can have unforeseen effects.

12. Windows XP can be very insistent about you checking for auto updates, registering a Passport, using Windows Messenger and so on. After a while, the nagging goes away, but if you feel you might slip the bonds of sanity before that point, run Regedit, go to HKEY_CURRENT_USER/Software/Microsoft/Windows/Current Version/Explorer/Advanced and create a DWORD value called EnableBalloonTips with a value of 0.

13. You can start up without needing to enter a user name or password. Select Run... from the start menu and type 'control userpasswords2', which will open the user accounts application. On the Users tab, clear the box for Users Must Enter A User Name And Password To Use This Computer, and click on OK. An Automatically Log On dialog box will appear; enter the user name and password for the account you want to use.

14. Internet Explorer 6 will automatically delete temporary files, but only if you tell it to. Start the browser, select Tools / Internet Options... and Advanced, go down to the Security area and check the box to Empty Temporary Internet Files folder when browser is closed.

15. XP comes with a free Network Activity Light, just in case you can't see the LEDs twinkle on your network card. Right click on My Network Places on the desktop, then select Properties. Right click on the description for your LAN or dial-up connection, select Properties, then check the Show icon in notification area when connected box. You'll now see a tiny network icon on the right of your task bar that glimmers nicely during network traffic.

16. The Start Menu can be leisurely when it decides to appear, but you can speed things along by changing the registry entry HKEY_CURRENT_USER/Control Panel/Desktop/MenuShowDelay from the default 400 to something a little snappier. Like 0.

17. You can rename loads of files at once in Windows Explorer. Highlight a set of files in a window, then right click on one and rename it. All the other files will be renamed to that name, with individual numbers in brackets to distinguish them. Also, in a folder you can arrange icons in alphabetised groups by View, Arrange Icon By... Show In Groups.

18. Windows Media Player will display the cover art for albums as it plays the tracks -- if it found the picture on the Internet when you copied the tracks from the CD. If it didn't, or if you have lots of pre-WMP music files, you can put your own copy of the cover art in the same directory as the tracks. Just call it folder.jpg and Windows Media Player will pick it up and display it.

19. Windows key + Break brings up the System Properties dialogue box; Windows key + D brings up the desktop; Windows key + Tab moves through the taskbar buttons.

Hope This gives you some Inside Info .. :)

Tuesday, July 1, 2008

USB Host Controller Driver Architecture

The universal serial bus (USB) driver architecture consists of a host computer, a physical bus, and one or more USB devices. The host computer contains two layers: an upper software layer, which includes USB device drivers, and a host controller hardware layer, also known as an adapter layer. The main responsibility of the host computer is to control data transfers to and from USB devices. USB devices are peripherals that use the USB electrical and data format specifications to communicate with the host computer. The physical bus is the set of USB cables that links the controller with the peripherals.

The following list shows the layers of the USB driver architecture:

  • Host Computer
  • Upper Software Layer with USB Devive drivers
  • Host Controller Layer or Adapter Layer
  • Physical Bus
  • USB

U USB Topology

The host computer is the root node of the USB tree and contains an implicit hub, called the root hub. A hub is a USB function that propagates USB data to one or more ports, thereby increasing the total number of functions that share the bus. A hub has one connection, called an upstream port, to higher levels of the USB tree. A hub can have any number of ports for connecting peripheral devices and other hubs. You can connect up to 127 devices, including hubs, to the host computer. Peripheral devices are always leaf nodes within a USB bus. However, as a matter of practical implementation, many USB peripheral devices have hubs integrated into them, so a user might not have to use separate USB hubs.

The following illustration shows a USB bus with several common peripherals connected.

In this example, the association of the mouse with the keyboard's internal hub and the speakers with the monitor's internal hub is arbitrary. You can connect the mouse to the monitor's internal hub, the modem to the keyboard's internal hub, and the speakers to the stand-alone hub in Tier 1 without affecting the system's functionality and without having to reconfigure software on the host computer. USB devices and their corresponding USB device drivers behave identically, regardless of the specific bus topology.

USB System Software


Universal serial bus (USB) system software consists of two layers, an upper layer of USB device drivers and a lower layer of USB functions. USB device drivers use the USB functions to establish connections to the devices they control and to configure and communicate with the devices. The lower layer of USB functions performs several interrelated tasks:

· Manage all communication between USB device drivers and the host computer's built-in USB root hub.

· Load and unload USB device drivers at the appropriate times.

· Translate data to and from the USB protocol's frame and packet formats.

· Perform generic configuration and status-related tasks by establishing communication with the generic endpoint on all USB devices.

The lower layer is itself composed of two parts, the upper USB driver module and the lower host controller driver (HCD) module. The USB driver module implements the high-level USB driver interface functions in terms of the functionality provided by the HCD module. USB device drivers use the USB driver interface functions to communicate with their peripherals. Use the functions that are provided by the USB driver to implement your USB device drivers.

The following illustration shows the two layers of software in the context of the host's USB hardware and a peripheral device.

During a data transfer, the flow of operation typically proceeds in the following sequence:

1. A USB device driver initiates transfers by using USB driver interface functions to issue requests to the USB driver module.

2. The USB driver module passes the requests to the HCD module.

3. The HCD module divides requests into individual transactions, based on its knowledge of the bus and on characteristics of the USB devices that are connected to the bus, and schedules these transactions over the bus.

4. The host controller hardware performs or completes the transactions.

All transactions on the bus originate from the host side; the peripherals are totally dependent


USB Device

Universal serial bus (USB) peripheral devices consist of one or more logical components, called interfaces, that implement the abilities of the devices. Although each interface provides a useful grouping of functionality, precisely what constitutes an interface is an implementation detail. For example, a USB mouse device could present one interface for horizontal-movement and vertical-movement information and a separate interface for left-button and right-button information. As another option, the device could present a single interface containing all of the information. Both are valid approaches, but each approach has implications for how the device driver must operate.

Associated with each interface is a set of endpoints. Endpoints are the ultimate producers or consumers of data that is transmitted across the bus. All USB devices have a special endpoint, known as endpoint 0, which supports the generic USB status and configuration protocol.

USB device drivers establish logical communication channels, called pipes, to the various endpoints on a USB device. A pipe is a software association between a USB device driver and an endpoint. Pipes can be thought of as communication channels that use function calls to the USB system software to communicate with their associated endpoints. The characteristics of a pipe, such as the direction of communication and the supported transfer type, are determined by the endpoint characteristics, which in turn are indicated in the endpoint descriptor structure obtained from the device.

The bus interface hardware on a USB device is responsible for the transmission and reception of USB-structured data. The logical USB device corresponding to a physical USB device consists of USB abstraction entities, such as the device endpoints and their corresponding pipes.

The USB system loads the driver for every interface that is specified by a multiple-interface USB device. You can still load one driver for all the interfaces in this device through the registry.