I know after Windows XP release Universal USB Storage Driver is not an issue for any USB. Two days back, I was facing USB detection issue. My Computer was not recognizing my portable hard disk either. Finally on Sunday, I got two hours to fix critical problem and share my findings with you with solution. I am share my findings based on Microsoft Windows 7 only.

"USBSTOR.sys" file is USB Mass Storage Driver for detect USB Mass Storage Device(s). You can find it in folder location "C:\Windows\System32\drivers". ‘.SYS’ files communicate with Operating System directly and guide Operating System what to do with device and how to do.

Operating System has one utility (so called, Driver Detection/New Hardware Found) for new device detection and registration for correct version of device driver to communicate with Operating System. Driver Detection utility needs INF and PNF file for device detection and registration for communication with hardware. You can find them in folder location, "C:\Windows\inf".

[Additional Information, INF file has all driver setup information and PNF file has some dependency and additional information of driver (in nontechnical words) (Technical team is Precompiled Setup Information).]

Some time USB Mass Storage Device has problems due to driver installation and un-installation frequently OR due to any possible bug of installer/setup. Installer can delete .INF, .PNF and/or .SYS file(s).

Windows 7 has almost every Device Driver backup in folder location, "C:\Windows\System32\DriverStore\FileRepository\". Go there and search folder "USBStor.inf_******" (* is driver identity number). It will have three files of USB Mass Storage Driver. Please follow instructions to restore them,

1. Copy "usbstor.inf" file and "usbstor.pnf" file, and place in location "C:\Windows\inf".

2. Copy "usbstor.sys" file and place in location "C:\Windows\System32\drivers".

3. Reboot Operating System.

4. Say AHO! After login. (Please note without AHO! USB will not work. A Joke)

5. Insert USB and use it.

Again AHO!


You can learn easily by Google, ‘How to use .config file in log4net?’. My project has two different type of logging file. I want to centralize logging location configurable. Following code will help you to read log4net “File Appender” to get “File” tag value (file path).

public static log4net.Appender.IAppender[] GetAllAppenders()
        {
            ArrayList appenders = new ArrayList();
            log4net.Repository.Hierarchy.Hierarchy h =
                (log4net.Repository.Hierarchy.Hierarchy)log4net.LogManager.GetLoggerRepository();
            appenders.AddRange(h.Root.Appenders);
            return (log4net.Appender.IAppender[])appenders.ToArray(typeof(log4net.Appender.IAppender));
        }

This function will give you all Appenders defined under log4net tag in .config file.

        public static FileAppender GetFileAppender()
        {
            IAppender[] appenderList = GetAllAppenders();
            FileAppender fileAppender = null;
            foreach (IAppender appender in appenderList)
            {
                if (appender.GetType().FullName == typeof(RollingFileAppender).FullName)
                {
                    fileAppender = (FileAppender)appender;
                    break;
                }
            }
            return fileAppender;
        }

This function will give return File Appender to get all information defined regarding File in RollingFileAppender under log4net tree.

FileAppender apprender = GetFileAppender();
log_path = apprender.File;

This code will give you File Path defined in .config file using log4net tag tree. FileAppender instance has some other useful information which may required in any log as per need.

Best of Luck!
End with Aho!



Outlook2007 by aimslife.

1. Right-click on the Outlook icon in the Notification Area, next to the clock.

2. In the resulting menu, select Hide When Minimized.


Sample code can help you to use excel sheet as database.

private static OleDbDataReader myReader;
private static DBManager dbObject;
public static void readDatabaseDate( string filePath, string selectQuery )
{
  String conString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + filePath + ";" + "Extended Properties=Excel 8.0;";
  dbObject = new DBManager( conString );
  dbObject.open( );
  myReader = dbObject.SelectQuery( selectQuery );
}

Select Query will be "SELECT * FROM [Sheet1$A5:BU65536]".

C# always make our life easy.

Enjoy and say AHO!


unsigned short ComputeChecksum(unsigned short *data, int size)
{
    register int nleft=size;
    unsigned long checksum = 0;
    while(nleft>1)
    {
        checksum=checksum+*data++;
        nleft=nleft-sizeof(unsigned short);
    }
    if(nleft)
        checksum=checksum+*(unsigned char*)data;
    checksum=(checksum>>16)+(checksum&0xffff);
    checksum=checksum+(checksum>>16);
    return (unsigned short)(~checksum);
}

You can translate above code in any language (either Java or C#). It was written in C language.


Construction of Pakistan Flag by aimslife.    Pakistan Flag by aimslife.

"That this assembly resolves that the national flag of the federation of Pakistan be of the following description.

"A dark green rectangular flag in the proportion of length and width 3:2 with a white vertical bar at the mast, the green portion bearing a white crescent in the centre and a five-pointed white heraldic star. The size of the white portion being one-fourth the size of the flag, nearest the mast, the remainder three-fourths being dark green. the dimensions of the crescent and star are obtained as follows:

"Draw the diagonal from the top right hand corner to the bottom left corner of the green portion. On this diagonal establish two points ‘A’ and ‘B’. Point ‘A’ at a distance equidistant from top right and bottom left hand corners of the green portion, i.e. the centre of the green portion. Point ‘B’ at a distance from the top right hand corner equal to 13/20th the width of the flag. With centre point ‘A’ and radius 1.1/4th the width of the flag describe a second arc. The enclosures made by these two arcs form the crescent. The dimensions of the five-pointed white heraldic star are determined by drawing a circle 1/10th the width of the flag. The circle surrounds the five points of the heraldic star. The star lies with one point on the diagonal at a point where the larger arc of the crescent, if completed, cuts the diagonal."

 

Special thanks to pakistani.org and flagspot.net.

Text taken from http://www.pakistani.org/pakistan/flagspec.html
Image taken from http://flagspot.net/flags/pk’.html


Debugging is always pay important role in software development life cycle. You can make your life easy with the help of macros. With the help of macros you can enable and disable debugging and can define debugging level.

/**
* LOGGING LEVEL
* ***************
* Macro                        Reason
* ****************************************************************************************************************
* __DEBUG_LEVEL_LOG__          Complete logging including debug level, info level, warning level and error level
* __INFO_LEVEL_LOG__           Logging including info level, warning level and error level
* __WARNING_LEVEL_LOG__        Logging including warning level and error level
* __ERROR_LEVEL_LOG__          Logging including error level
*
* __DEBUG_LEVEL_LOG_ONLY__     Logging of debug level only
* __INFO_LEVEL_LOG_ONLY__      Logging of info level only
* __WARNING_LEVEL_LOG_ONLY__   Logging of warning level only
* __ERROR_LEVEL_LOG_ONLY__     Logging of error level only
*
**/

#define __DEBUG_LEVEL_LOG__
#define __PRINT_LEVEL_LOG__
#define __LINUX_USER_SPACE__ // __LINUX_KERNEL_SPACE__

#ifdef __DEBUG_LEVEL_LOG__
        #define __INFO_LEVEL_LOG__
        #define __WARNING_LEVEL_LOG__
        #define __ERROR_LEVEL_LOG__
#endif

#ifdef __INFO_LEVEL_LOG__
        #define __WARNING_LEVEL_LOG__
        #define __ERROR_LEVEL_LOG__
#endif

#ifdef __WARNING_LEVEL_LOG__
        #define __ERROR_LEVEL_LOG__
#endif

#ifdef __DEBUG_LEVEL_LOG_ONLY__
    #define __DEBUG_LEVEL_LOG__
#endif

#ifdef __INFO_LEVEL_LOG_ONLY__
    #define __INFO_LEVEL_LOG__
#endif

#ifdef __WARNING_LEVEL_LOG_ONLY__
    #define __WARNING_LEVEL_LOG__
#endif

#ifdef __ERROR_LEVEL_LOG_ONLY__
    #define __ERROR_LEVEL_LOG__
#endif

#ifdef __PRINT_LEVEL_LOG__
  #ifdef __LINUX_KERNEL_SPACE__
    #define print(format, …) printk(format, ## __VA_ARGS__);
  #endif
  #ifdef __LINUX_USER_SPACE__
    #define print(format, …) printf(format, ## __VA_ARGS__);
  #else
    #define print(format, …)
  #endif
#else
    #define print(format, …)
#endif

#ifdef __DEBUG_LEVEL_LOG__
    #define debug(format, …) { \
        print("DEBUG   : [%s() : %s : %d] : ", __FUNCTION__, __FILE__, __LINE__); \
        print(format, ## __VA_ARGS__); \
        print("\n"); \
    }
#else
    #define debug(format, …)
#endif

Please create "info, warning and error" logging statement according to Debugging Logging macro. First three macros will help us to enable/disable logging and defines logging level.

Enjoy it! and say "AHO!"


Although windows have “itoa” function but I did not find it in Linux. That time, I did Google and found a beautiful function for conversion of integer value into character string. Sample code is given below,

#include <stdio.h>

void main()
{
  char fun[80];
  int value = 1943743;
  sprintf(fun, "%d", value);
}

Enjoy and say AHO!


Express your feeling with actions.

پاکستان ایک عشق ایک جنوں

Pakistan Zindabad!

Express Your Love by you.


تلاش کرتا ہو خود میں ایسا جذبہ جسے اندیشہ زوال نہ ہو

مگربہت تلاش پر بھی نہ ملا جس پر یہ سوال نہ ہو

By AimsLife


Today, I am going to share some development guide lines for develop Linux-Kernel Module with NetFilter. Inshah-Allah! It will be helpful for newbie.

  1. Before anything, you should do pencil work around your problem/task and LAB setup.
  2. After complete your LAB setup, your should take understanding of all technologies related to development task. These are given below,
    1. Linux Kernel Version Understanding, Selection and Compilation.
      1. I would recommend to read compilation article. You will learn a lot but for shortcut, I am listing following commands that will be use for Linux Kernel Compilation.
        1. # cd /tmp
        2. # wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.25.tar.gz
        3. # tar –zxvf linux-2.6.25.tar.gz –C /usr/src
        4. # cd /usr/src
        5. # make menuconfig
        6. # make
        7. # make modules
        8. # make modules_install
        9. # make install
        10. (Reboot system and enjoy Linux-2.6.25 Kernel)
    2. Linux Kernel Code Reading (I use vs2k5 IDE for code reading, if you know any good Open Source IDE then please let me).
    3. Linux Kernel Module Programming with v2.6 (html, pdf) including memory allocation and deletion (first, second).
    4. Protocol Understanding at packet level.
    5. Understanding of NetFilter Programming (first, second, third).
    6. Understanding of SK_BUFF structure for packet operation (first, second, third, fourth, fifth).
    7. Good development practices.
  3. Start Development and after complete your task say, “AHO!”.

I have developed Linux Kernel Driver (for Linux Kernel 2.6.25) for Gateway with in fifteen days to change one of the protocol behavior. I did not have any Linux development experience before this task. I am dimmest person in world but you are not. You can do it! Come On Say, “YES, I Can!”. Don’t forget to say, “AHO!” after complete your task.


Special thanks to OSROnline group to publish a great article on use of malloc, free, new and delete function in DDK.

Article link has given below,

Global Relief Effort – C++ Runtime Support for the NT DDK
The NT Insider, Vol 6, Issue 3, May-Jun 1999 | Published: 15-Jun-99| Modified: 16-Aug-02
[link] http://www.osronline.com/article.cfm?id=57


Following commands can give network connections information,

  1. # netstat -tulpan
  2. # lsof –i

Command#1 (netstat –tulpan) will give you connections information, but I did not find any way to kill connection after get information from it.

Command#2 (lsof –i) will give you useful connections information and PID of connections as well. You can kill that session using PID.


Given code is working perfect to generate new copy of NDIS_PACKET,

NDIS_STATUS
CreateNewSendNdisPacket(IN NDIS_HANDLE SendPacketPoolHandle,
                        IN PNDIS_PACKET pkt_old,
                        IN PGUINT8 pkt_raw,
                        IN GUINT32 pkt_len,
                        OUT PNDIS_PACKET * pkt_new)
{
  NDIS_STATUS Status;
  NdisDprAllocatePacket(&Status, pkt_new, SendPacketPoolHandle);
  if(Status == NDIS_STATUS_SUCCESS)
  {
    PNDIS_BUFFER  MyBuffer;
    PSEND_RSVD    SendRsvd;

    SendRsvd = (PSEND_RSVD)((*pkt_new)->ProtocolReserved);
    SendRsvd->OriginalPkt = pkt_old;
    NdisAllocateBuffer(&Status, &MyBuffer, SendPacketPoolHandle, pkt_raw, pkt_len);
    if(Status == NDIS_STATUS_SUCCESS)
    {
      NdisChainBufferAtFront((*pkt_new), MyBuffer);
      (*pkt_new)->Private.Flags = NdisGetPacketFlags(pkt_old);
    }
  }
  return Status;
}

NDIS_STATUS
CreateNewRecvNdisPacket(IN NDIS_HANDLE RecvPacketPoolHandle,
                        IN PNDIS_PACKET pkt_old,
                        IN PGUINT8 pkt_raw,
                        IN GUINT32 pkt_len,
                        OUT PNDIS_PACKET * pkt_new)
{
  NDIS_STATUS Status;

  NdisDprAllocatePacket(&Status, pkt_new, RecvPacketPoolHandle);
  if(Status == NDIS_STATUS_SUCCESS)
  {
    PNDIS_BUFFER MyBuffer;
    PRECV_RSVD   RecvRsvd;

    RecvRsvd = (PSEND_RSVD)((*pkt_new)->MiniportReserved);
    RecvRsvd->OriginalPkt = pkt_old;

    NdisAllocateBuffer(&Status, &MyBuffer, RecvPacketPoolHandle, pkt_raw, pkt_len);
    if(Status == NDIS_STATUS_SUCCESS)
    {
      NdisChainBufferAtFront((*pkt_new), MyBuffer);
      (*pkt_new)->Private.Flags = NdisGetPacketFlags(pkt_old);
    }
  }
  return Status;
}

Don’t forget to delete memory after send complete. I have used above functions in PassThru example of NDIS-WDK.


Given code can help you to compute checksum.

/* pseudo header for checksum calculation */
typedef struct pseudoh {
    guint32 src_addr;
    guint32 dest_addr;
    guint8  zero;
    guint8  protocol;
    guint16 length;
} PSEUDO_HDR, * PPSEUDO_HDR;

/* Compute Checksum for TCP packets */
GUINT16 ComputeChecksum(PGUINT16 pseudo_hdr, PGUINT16 ptcp_hdr, PGUINT16 pdata, GUINT32 dataSize) {

  guint32 checksum = 0;
  guint32 nleft = 0;

  nleft = SIZE_PSEUDO_HDR;
  while(nleft > 1) {
    /*  This is the inner loop */
    checksum = checksum + *(pseudo_hdr++);
    nleft = nleft – sizeof(guint16);
  }

  nleft = SIZE_TCP_HEADER;
  while(nleft > 1) {
    /*  This is the inner loop */
    checksum = checksum + *(ptcp_hdr++);
    nleft = nleft – sizeof(guint16);
  }

  nleft = dataSize;
  while(nleft > 1) {
    /*  This is the inner loop */
    checksum = checksum + *(pdata++);
    nleft = nleft – sizeof(guint16);
  }
  if(nleft)
    checksum = checksum + *((pguint8)pdata);
  /*  Fold 32-bit sum to 16 bits */
  checksum = (0xFFFF&(checksum >> 16)) + (checksum & 0xffff);
  checksum = (checksum & 0xffff) + (0xFFFF&(checksum >> 16));
  return (guint16)(~checksum);
}


Pakistan Win! الله اکبر

Icc-world-twenty20-2009 by you.


This setting will enables for you to control automatic rebooting of the system after the crash. After the crash, you must be able to check the reason of the crash and for that, the system should not reboot. Therefore, it is very necessary to control the automatic rebooting of the system.

Path:  [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl\]
Location: Local Machine
Value Name: AutoReboot
Data Type: DWORD (DWORD Value)
Enabled Value: 0
Disabled Value: 1
Action Type: Modified


While working on Microsoft Device Driver domain, I found following most active and helpful forums,

1) OSR-Online: http://www.osronline.com
You can configure OSR-Online forum on email client and given client will be helpful for you.
http://www.osronline.com/page.cfm?name=NewsReaderInfo

2) Microsoft NNTP Server: msnews.microsoft.com
Following groups are available on Microsoft forum,
1. microsoft.public.development.device.drivers
2. microsoft.public.windowsxp.device_driver.dev
You can configure Microsoft NNTP server on email-client using above “OSR-Online Forum Configuration” process but you will use “msnews.microsoft.com” for Microsoft NNTP Server address. You will not need authentication cardinality to connect Microsoft NNTP Server.

NOTE: Some time few consultants will discourage you to use forums for help and will ask you to get consultancy from them. Please do not underestimate yourself and try google and other forums for help because “Everything possible but nothing is impossible”.


I faced given compilation error after convert “Komodia Project” from “VC6” to “VS2K5”.

Error    1    Command line error D8004 : ‘/D’ requires an argument    cl

Solution:

Remove “/D” from “Additional options” (Example image is given below).
Path of “Additional options” is “Project Properties” >> “Configuration Properties” >> “C/C++” >> “Command Line”

Komodia_Project_Error by you.


Special thanks to Hollis Technology Solution to write script for build DDK source with vs2k5.
[link] http://www.hollistech.com/Resources/ddkbuild/ddkbuild3_14.zip

Following Environment variables need to use DDKBuild v3.14 script with vs2k5. I am using WDK 6001.18002. Don’t open vs2k5 before do following configuration.

  1. Name: WINDDK
    Value: C:\WinDDK\
  2. Name: WLHBASE
    Value: C:\WinDDK\6001.18002\
  3. Edit “Path” variable and add “%WINDDK%;” string at the end of “Path” variable.
  4. Copy “ddkbuild.bat” file on “C:\WinDDK\” location.

Open vs2k5 environment using “devenv” command. Create “Makefile based project” and set configuration according to image.

ddkbuild_3.14_configuration_stime by you.

You can set build commands after create project. All you need to set build command according to given image.

ddkbuild_3.14_configuration by you.

Build Command Line: ddkbuild –WLHXP checked .
Rebuild Command Line: ddkbuild –WLHXP checked . –ceZ

I have configured WinDDK with DDKBuild_3.14 for WindowsXP. Please change configurations parameters according to your Microsoft Operating System.


Following POSIX Regular Expression will be needed commonly while developing application,

ALPHA_REG_EXPRESSION = "[a-zA-Z ]*"

ALPHA_UNDERSCORE_REG_EXPRESSION = "[a-zA-Z_ ]*"

ALPHA_NUMERIC_REG_EXPRESSION = "[a-zA-Z0-9 ]*"

ALPHA_NUMERIC_UNDERSCORE_REG_EXPRESSION = "[a-zA-Z0-9_ ]*"

ALPHA_NUMERIC_UNDERSCORE_DASH_REG_EXPRESSION = "[a-zA-Z0-9_[-] ]*"

DECIMAL_REG_EXPRESSION = "[0-9]*[.][0-9]*"

INTEGER_REG_EXPRESSION = "([1-9][0-9]*)|0"

ADDRESS_REG_EXPRESSION = "[,.#_a-zA-Z0-9- ]*"

IP_REG_EXPRESSION = "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"

EMAIL_REG_EXPRESSION = "[a-zA-Z0-9._]*@[a-zA-Z0-9 ]*.[a-zA-Z]*"

EMAIL_REG_EXPRESSION = "\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}\\b"

MAC_REG_EXPREESION = "([0-9a-fA-F][0-9a-fA-F]-){5}([0-9a-fA-F][0-9a-fA-F])"

MAC_REG_EXPREESION = "[0-9A-Fa-f[-] ]*"

ZIPCODE_REG_EXPRESSION = "([0-9a-zA-Z]{5})|([0-9a-zA-Z]{7})|([0-9a-zA-Z]{9})|([0-9a-zA-Z]{11})"

NUMERIC_DASH_REG_EXPRESSION = "[0-9- ]*"


I always face one problem on fresh Eclipse Ganymede installation, How I can install subversion on it?

You can install Subversion on Eclipse Ganymede, in two step,

1. Install SVN Team Provider from

http://download.eclipse.org/technology/subversive/0.7/update-site/

2. After installing SVN Team Provider and restart Eclipse then install SVN
connectors from

http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/


# synergyc –f –d ERROR –daemon <server_ip_address>

I recommend to add this command on “/etc/rc.local” file for automatic start synergy client at login time.

[Synergy]


For uninstall/repair Windows Live Messenger 2009, you have to use "Windows Live Essentials" from “Add/Remove Programs”. Image will help you a lot.

Windows Live Messenger by you.




Follow

Get every new post delivered to your Inbox.