BUG: Access Violation When You Call com.ms.util.EventLog on Japanese Windows NT-Based Computer (293804)



The information in this article applies to:

  • Microsoft virtual machine

This article was previously published under Q293804

SYMPTOMS

When you call com.ms.util.EventLog on a Japanese Microsoft Windows NT-based computer, an access violation may occur.

RESOLUTION

Instead of using com.ms.util.EventLog, use J/Direct to call the EventLog function directly. For example:
import com.ms.win32.*;


public class test2
{
    public boolean writeToEventLog()
    {
        int handle = 0;
        boolean bRes = false;
    
        handle = RegisterEventSource (null, "JDirect Event Log Sample");

        if (handle == 0)
        {
            System.out.println ("Could not register the event source.");
        }
        else
        {
            short i, j;
            i = 0;
            j = 0;

            String str [] = new String[1];
            str[0] = 
"\u30de\u30a4\u30af\u30ed\u30bd\u30d5\u30c8\u306e\u958b\u767a\u8005\u30b5\u30dd\u30fc\u30c8";

            bRes = ReportEvent (handle, i, j, 0, 0, (short)1, 0, str, 0); 
            if (!bRes)
            {
                System.out.print("ReportEvent returned error code of: ");
                System.out.println(com.ms.dll.DllLib.getLastWin32Error());
            }
        }

        bRes = DeregisterEventSource(handle);
        return bRes;
    }

    public static void main (String args[])
    {
        test2 t = new test2();
        boolean bRes = t.writeToEventLog();
        System.out.println (bRes?"PASS":"FAIL");
    }


    /** @dll.import("Advapi32", auto, setLastError) */ 
    public native static int RegisterEventSource(String lnUNCServerName, 
                                                          String lpSourceName);
    
    /** @dll.import("Advapi32", auto, setLastError) */ 
    public native static boolean DeregisterEventSource(int hEventLog);

    /** @dll.import("Advapi32", auto, setLastError) */ 
    public native static boolean ReportEvent(int hEventLog,
                                             short wType,
                                             short wCategory,
                                             int dwEventID,
                                             int lpUserSid,
                                             short wNumStrings,
                                             int dwDataSize,
                                             String [] lpStrings,
                                             int lpRawData);

}
				

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

To reproduce this behavior, compile and run the following code on a Japanese Windows NT 4.0 Server:
class test
{

  public static void main(String args[])
  {

    com.ms.util.EventLog eventLog = new com.ms.util.EventLog("J/Direct Event Log Sample");
			
    String str = 
"\u30de\u30a4\u30af\u30ed\u30bd\u30d5\u30c8\u306e\u958b\u767a\u8005\u30b5\u30dd\u30fc\u30c8";
									
    short i, j;
			
    i = 0;
    j = 0;
						
    eventLog.reportEvent(i, j, 0, str);		
}
				

REFERENCES

For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:6/14/2006
Keywords:kbBug kbLocalization kbnofix KB293804