2007-01-27

A USB Disk Virus

My younger sister came to Beijing, and gave me her little USB disk. She said there was a virus. It was effected in the network in her office. There are a lot of viruses wandering on their network from computer to computer. Even they installed various virus killers, the situation remained unchanged.

I had no idea about USB viruses. Maybe this is the first time I was facing this kind of thing. I plugged the disk into the USB port of my notebook. I am not afraid of it because I have Norton Anti-Virus. After scaned, Norton reported there is a malware named iexplorer.exe under iexplorer directory. The virus tries to fool user it is a copy of the famous Internet Explorer!

How does it take action? When we click the icon of the removable disk in the window of My Computer, by default, autorun.inf on this disk is loaded and something will be executed. At this moment, the virus hides itself in memory waiting for the opportunity to copy itself to a new USB disk.

It is possible to disable the autorun feature by modifing some key values in the Registry of Windows. But it is not a wise idea. More often we need this feature. There is a best practice in using a USB disk or other removable devices. You can keep pressing the Shift key when you plug the disk. In this case autorun is skipped. And then, open your virus scanner. Remove autorun.inf. For a USB disk, you actually don't need it. Be cautious after you use your disk in other computers.

Labels: , ,

2007-01-21

Reading File in a Multi-Thread Environment

A file can be opened separately in a multi-thread environment, but it can not be read independently. It seems there is a unique reading pointer inside OS. When a thread reads some bytes, the pointer is advanced, and other threads will continue reading from the new position. To control the reading behaviour, file operations must be synchronized. Look at the following piece of code:

unsigned long pos = 0;
unsigned long bytesRead = 0;
for (;;) {
    mutex_->captureObject();
    fseek(f, pos, SEEK_SET);
    bytesRead = fread(buffer, 1, BUFFSIZE, f);
    mutex_->releaseObject();
    if (bytesRead <= 0)
        break;
    pos += bytesRead;
    .......
}

A mutex object is used to synchronize file operations.

2007-01-13

Change IP Address in a Script

We usually change the IP address of the network card of our computer with a graphic tool. This work can also be done in a command prompt. Sometimes it is useful. Follow me:

C:\>ipconfig
Windows 2000 IP Configuration

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 10.0.127.235
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.0.127.1

C:\>netsh
netsh>i
interface>i
interface ip>sh a

Configuration for interface "Local Area Connection"
DHCP enabled: No
IP Address: 10.0.127.235
SubnetMask: 255.255.255.0
Default Gateway: 10.0.127.1
GatewayMetric: 1
InterfaceMetric 1

interface ip>set a "Local Area Connection" static 192.168.16.44 255.255.255.0 192.168.16.5 1
Ok.

interface ip>sh a

Configuration for interface "Local Area Connection"
DHCP enabled: No
IP Address: 192.168.16.44
SubnetMask: 255.255.255.0
Default Gateway: 192.168.16.5
GatewayMetric: 1
InterfaceMetric 1

interface ip>exit

C:\>ipconfig

Windows 2000 IP Configuration

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.16.44
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.16.5

If you want to set it as DHCP, try this:

interface ip>set a "Local Area Connection" source=dhcp

Administrator permission is required for this work.

2007-01-12

Amazon Forest to Farms

I was heavily shocked by the cover of the January release of the National Geographic when I saw it today on a bookshelf of the Wangfujing Bookstore, Beijing. The title "Amazon Forest to Farms" is printed over a picture of farmland, a common landscape of the vast plain of central China. The land is cultivated perfectly by advanced machinery, except a little lonely tree standing in the middle. Nobody can imagine it is a snapshot of the Amazon region. Amazon forest is dubbed as the lung of the Earth. At this moment I just feel hard to breath. The little tree is telling a horrific story why it is there and how long it will be there.

When I showed the magazine to my friend, a foreigner in IT industry as myself, he has no semantic linkage between Amazon and Forest, of course, no idea why this title goes to the cover page of this famous magazine. He talked to me the Amazon in the United States and made me astonished.

The story is quite simple. Where did these trees go? They went to paper mills, to publishers’ workshops, to shelves of bookstores and finally the Internet. The Amazon in the South America might disappear soon, but it lives on the Internet in the United States of America. There is no evidence that the Amazon in the digital era can last forever.

Disable JIT to Obtain Line Number in Stack Trace

IBM JVM can optimize a Java class. In this case, when an exception's stack trace is printed, you may find there is no line number for some classes. It is diffuclt for you to figure out the problem:

at com.vitria.bpe.runtime.EventUtil.isTimerEvent(Compiled Code)
at com.vitria.bpe.process.states.BPBasicStateImpl.applyRulesRegular(Compiled Code)
at com.vitria.bpe.process.states.BPActionStateImpl.onEntry(Compiled Code)
at com.vitria.bpe.process.states.BPBasicStateImpl.applyPolicy(Compiled Code)

We can disable JVM's JIT feature in following way:

Go to WebSphere's console: Application servers > server1 > Process Definition > Java Virtual Machine
And select the check box of "Disable JIT".
Save the new configuration and restart WebSphere.

2007-01-11

Manually Install Customer Service in WebSphere 6.1

Manually install the service:
  1. Open the console of WebSphere. Go to Servers -> Application Servers. Select server1 for example.
  2. On Configuration tab, select Server Infrastructure -> Administration -> Administration Services.
  3. On Configuration tab, select Extension MBean Provider.
  4. Click New.
  5. Input Name as MyServiceMBean, Classpath as ${WAS_LIBS_DIR}/myjar.jar, Description as Administration MBean. Click OK, and save the changes. The JAR file contains the classes implementing this service.
  6. Select the record MyServiceMBean just created. The bean name MyServiceMBean is defined in the XML MyService.xml file.
  7. Select the extensionMBeans on Additional Properties column.
  8. Click New.
  9. Input DescriptorURI as MyService.xml, type as MyServiceMBean. Click OK, and save the changes.
  10. Go to Servers -> Application Servers. Select server1.
  11. On Configuration tab, select Server Infrastructure -> Administration -> Custom Services.
  12. Click New.
  13. Check the option Enable service at server startup. Input Classname as mypackage.MyServiceMBean, Display Name as "My Service MBean", Classpath as ${WAS_LIBS_DIR}/myjar.jar. Click OK, and save the changes.
  14. Restart WebSphere server.