Author: carnold
Date: Thu Aug 21 15:33:14 2008
New Revision: 687885

URL: http://svn.apache.org/viewvc?rev=687885&view=rev
Log:
Bug 44386: NTEventLogAppender.dll for Windows 64

Added:
    logging/log4j/trunk/src/ntdll/NTEventLogAppender.def
Modified:
    logging/log4j/trunk/pom.xml
    logging/log4j/trunk/src/changes/changes.xml
    
logging/log4j/trunk/src/main/java/org/apache/log4j/nt/NTEventLogAppender.java
    logging/log4j/trunk/src/ntdll/   (props changed)
    logging/log4j/trunk/src/ntdll/NTEventLogAppender.rc
    logging/log4j/trunk/src/ntdll/build.xml
    logging/log4j/trunk/src/ntdll/nteventlog.cpp

Modified: logging/log4j/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/logging/log4j/trunk/pom.xml?rev=687885&r1=687884&r2=687885&view=diff
==============================================================================
--- logging/log4j/trunk/pom.xml (original)
+++ logging/log4j/trunk/pom.xml Thu Aug 21 15:33:14 2008
@@ -15,6 +15,17 @@
  limitations under the License.
 
 -->
+<!--
+Usage notes:
+
+To build NTEventLogAppender.dll using MinGW, place mingw\bin on path for 
Windows or install mingw
+package on other platforms.  Build will execute gcc and windres on Windows and
+i586-mingw32msvc-gcc and i586-mingw32msvc-windres on other platforms.
+
+To build NTEventLogAppender.dll using Microsoft tools, run the appropriate 
vcvars for the
+target platform and specify -Dntdll_target=msbuild on the mvn command line.
+
+-->        
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
   <modelVersion>4.0.0</modelVersion>
   <groupId>log4j</groupId>
@@ -165,7 +176,7 @@
             <id>ntdll</id>
             <configuration>
               <tasks>
-                <ant antfile="src/ntdll/build.xml">
+                <ant antfile="src/ntdll/build.xml" target="${ntdll_target}">
                   <property name="target.dir" location="target"/>
                   <property name="classes.dir" location="target/classes"/>
                   <property name="src.dir" location="src/ntdll"/>
@@ -402,6 +413,7 @@
       <properties>
         <tools.jar>${java.home}/../Classes/classes.jar</tools.jar>
         <m2_repo>${user.home}/.m2/repository</m2_repo>
+        <ntdll_target>build</ntdll_target>
       </properties>
     </profile>
     <profile>
@@ -412,6 +424,7 @@
       <properties>
         <tools.jar>${java.home}/../lib/tools.jar</tools.jar>
         <m2_repo>${user.home}/.m2/repository</m2_repo>
+        <ntdll_target>build</ntdll_target>
       </properties>
     </profile>
   </profiles>

Modified: logging/log4j/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/logging/log4j/trunk/src/changes/changes.xml?rev=687885&r1=687884&r2=687885&view=diff
==============================================================================
--- logging/log4j/trunk/src/changes/changes.xml (original)
+++ logging/log4j/trunk/src/changes/changes.xml Thu Aug 21 15:33:14 2008
@@ -60,6 +60,7 @@
        <action action="fix" issue="45635">Support -Dm2_repo option on Maven 
build for non-default Maven repository location.</action>
        <action action="fix" issue="45636">2 tests for DateLayout are failing 
because of ill initialized DateFormat.</action>
        <action action="fix" issue="45659">Incorrect user mailing list 
URL.</action>
+       <action action="fix" issue="44386">NTEventLogAppender.dll for 64-bit 
editions for Microsoft Windows.</action>
     </release>
 
   

Modified: 
logging/log4j/trunk/src/main/java/org/apache/log4j/nt/NTEventLogAppender.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/nt/NTEventLogAppender.java?rev=687885&r1=687884&r2=687885&view=diff
==============================================================================
--- 
logging/log4j/trunk/src/main/java/org/apache/log4j/nt/NTEventLogAppender.java 
(original)
+++ 
logging/log4j/trunk/src/main/java/org/apache/log4j/nt/NTEventLogAppender.java 
Thu Aug 21 15:33:14 2008
@@ -30,14 +30,16 @@
    <p><b>WARNING</b> This appender can only be installed and used on a
    Windows system.
 
-   <p>Do not forget to place the file NTEventLogAppender.dll in a
-   directory that is on the PATH of the Windows system. Otherwise, you
-   will get a java.lang.UnsatisfiedLinkError.
+   <p>Do not forget to place an NTEventLogAppender.dll
+   or "NTEventLogAppender" + System.getProperty("os.arch") + ".dll"
+   on the path to provide the native functions used by this appender
+   or the appender will not function.
 
    @author <a href="mailto:[EMAIL PROTECTED]">Chris Taylor</a>
    @author <a href="mailto:[EMAIL PROTECTED]">Jim Cakalic</a> */
 public class NTEventLogAppender extends AppenderSkeleton {
   private int _handle = 0;
+  private long handle64 = 0;
 
   private String source = null;
   private String server = null;
@@ -74,10 +76,15 @@
     }
 
     try {
-      _handle = registerEventSource(server, source);
-    } catch (Exception e) {
+      handle64 = registerEventSource64(server, source);
+    } catch(UnsatisfiedLinkError le) {
+        try {
+                       _handle = registerEventSource(server, source);
+               } catch (Throwable e) {
+                       e.printStackTrace();
+               }
+    } catch (Throwable e) {
       e.printStackTrace();
-      _handle = 0;
     }
   }
 
@@ -90,10 +97,24 @@
   void activateOptions() {
     if (source != null) {
       try {
-   _handle = registerEventSource(server, source);
-      } catch (Exception e) {
-   LogLog.error("Could not register event source.", e);
-   _handle = 0;
+          if (handle64 != 0) {
+             deregisterEventSource64(handle64);
+          } else if (_handle != 0) {
+             deregisterEventSource(_handle);
+        }
+      } catch(Throwable t) {          
+      }
+      try {
+         handle64 = registerEventSource64(server, source);
+      } catch(UnsatisfiedLinkError le) {
+          le.printStackTrace();
+          try {
+             _handle = registerEventSource(server, source);
+          } catch (Throwable e) {
+            LogLog.error("Could not register event source.", e);
+          }
+      } catch(Throwable e) {
+          LogLog.error("Could not register event source.", e);
       }
     }
   }
@@ -101,33 +122,51 @@
 
   public void append(LoggingEvent event) {
 
-    StringBuffer sbuf = new StringBuffer();
+    if (handle64 != 0 || _handle != 0) {
+        StringBuffer sbuf = new StringBuffer();
 
-    sbuf.append(layout.format(event));
-    if(layout.ignoresThrowable()) {
-      String[] s = event.getThrowableStrRep();
-      if (s != null) {
-   int len = s.length;
-   for(int i = 0; i < len; i++) {
-     sbuf.append(s[i]);
-   }
-      }
+        sbuf.append(layout.format(event));
+        if(layout.ignoresThrowable()) {
+            String[] s = event.getThrowableStrRep();
+            if (s != null) {
+                int len = s.length;
+                for(int i = 0; i < len; i++) {
+                    sbuf.append(s[i]);
+                }
+            }
+        }
+        // Normalize the log message level into the supported categories
+        int nt_category = event.getLevel().toInt();
+
+        // Anything above FATAL or below DEBUG is labeled as INFO.
+        //if (nt_category > FATAL || nt_category < DEBUG) {
+        //  nt_category = INFO;
+        //}
+        try {
+            if (handle64 != 0) {
+                reportEvent64(handle64, sbuf.toString(), nt_category);
+            } else {
+                reportEvent(_handle, sbuf.toString(), nt_category);
+            }
+        } catch(Throwable ex) {
+        }
     }
-    // Normalize the log message level into the supported categories
-    int nt_category = event.getLevel().toInt();
-
-    // Anything above FATAL or below DEBUG is labeled as INFO.
-    //if (nt_category > FATAL || nt_category < DEBUG) {
-    //  nt_category = INFO;
-    //}
-    reportEvent(_handle, sbuf.toString(), nt_category);
   }
 
 
   public
   void finalize() {
-    deregisterEventSource(_handle);
-    _handle = 0;
+    try {
+        if (handle64 != 0) {
+            deregisterEventSource64(handle64);
+            handle64 = 0;
+        }
+        if (_handle != 0) {
+            deregisterEventSource(_handle);
+            _handle = 0;
+        }
+    } catch(Throwable t) {
+    }
   }
 
   /**
@@ -155,8 +194,25 @@
   native private int registerEventSource(String server, String source);
   native private void reportEvent(int handle, String message, int level);
   native private void deregisterEventSource(int handle);
+  native private long registerEventSource64(String server, String source);
+  native private void reportEvent64(long handle, String message, int level);
+  native private void deregisterEventSource64(long handle);
 
   static {
-    System.loadLibrary("NTEventLogAppender");
+    try {
+        System.loadLibrary("NTEventLogAppender");
+    } catch(UnsatisfiedLinkError e) {
+        try {
+            String archLib = "NTEventLogAppender" + 
System.getProperty("os.arch");
+            try {
+                System.loadLibrary(archLib);
+            } catch(Throwable t) {
+                LogLog.error("Unable to load NTEventLogAppender.dll or " + 
archLib + ".dll.", t);
+            }
+        } catch(Throwable t) {
+            LogLog.error("Unable to load NTEventLogAppender.dll", e);
+        }
+    }
+
   }
 }

Propchange: logging/log4j/trunk/src/ntdll/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Aug 21 15:33:14 2008
@@ -1 +1,4 @@
 target
+NTEventLogAppender.res
+
+

Added: logging/log4j/trunk/src/ntdll/NTEventLogAppender.def
URL: 
http://svn.apache.org/viewvc/logging/log4j/trunk/src/ntdll/NTEventLogAppender.def?rev=687885&view=auto
==============================================================================
--- logging/log4j/trunk/src/ntdll/NTEventLogAppender.def (added)
+++ logging/log4j/trunk/src/ntdll/NTEventLogAppender.def Thu Aug 21 15:33:14 
2008
@@ -0,0 +1,22 @@
+;
+; Licensed to the Apache Software Foundation (ASF) under one or more
+; contributor license agreements.  See the NOTICE file distributed with
+; this work for additional information regarding copyright ownership.
+; The ASF licenses this file to You under the Apache License, Version 2.0
+; (the "License"); you may not use this file except in compliance with
+; the License.  You may obtain a copy of the License at
+; 
+;      http://www.apache.org/licenses/LICENSE-2.0
+; 
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;
+
+LIBRARY      "NTEventLogAppender"
+
+EXPORTS
+       DllRegisterServer   PRIVATE
+       DllUnregisterServer PRIVATE

Modified: logging/log4j/trunk/src/ntdll/NTEventLogAppender.rc
URL: 
http://svn.apache.org/viewvc/logging/log4j/trunk/src/ntdll/NTEventLogAppender.rc?rev=687885&r1=687884&r2=687885&view=diff
==============================================================================
--- logging/log4j/trunk/src/ntdll/NTEventLogAppender.rc (original)
+++ logging/log4j/trunk/src/ntdll/NTEventLogAppender.rc Thu Aug 21 15:33:14 2008
@@ -76,8 +76,8 @@
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION  1, 2, 15, 1
- PRODUCTVERSION 1, 2, 15, 1
+ FILEVERSION  1, 2, 16, 1
+ PRODUCTVERSION 1, 2, 16, 1
  FILEFLAGSMASK 0x17L
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -94,12 +94,13 @@
         BEGIN
             VALUE "CompanyName", "Apache Software Foundation"
             VALUE "FileDescription", "Platform methods for NTEventLogAppender"
-            VALUE "FileVersion", "1, 2, 15, 1"
+            VALUE "FileVersion", "1, 2, 16, 1"
             VALUE "InternalName", "NTEventLogAppender"
             VALUE "LegalCopyright",  "Licensed to the Apache Software 
Foundation (ASF) under one or more\ncontributor license agreements.  See the 
NOTICE file distributed with\nthis work for additional information regarding 
copyright ownership.\nThe ASF licenses this file to You under the Apache 
License, Version 2.0\n(the ""License""); you may not use this file except in 
compliance with\nthe License.  You may obtain a copy of the License at\n\n     
http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law 
or agreed to in writing, software\ndistributed under the License is distributed 
on an ""AS IS"" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
express or implied.\nSee the License for the specific language governing 
permissions and\nlimitations under the License."
             VALUE "OriginalFilename", "NTEventLogAppender.dll"
             VALUE "ProductName", "Apache log4j"
-            VALUE "ProductVersion", "1, 2, 15, 1" 
+            VALUE "ProductVersion", "1, 2, 16, 1"
+            VALUE "OLESelfRegister", "\0"
         END
     END
     BLOCK "VarFileInfo"

Modified: logging/log4j/trunk/src/ntdll/build.xml
URL: 
http://svn.apache.org/viewvc/logging/log4j/trunk/src/ntdll/build.xml?rev=687885&r1=687884&r2=687885&view=diff
==============================================================================
--- logging/log4j/trunk/src/ntdll/build.xml (original)
+++ logging/log4j/trunk/src/ntdll/build.xml Thu Aug 21 15:33:14 2008
@@ -16,6 +16,18 @@
 
 -->
 
+<!--
+Usage notes:
+
+To build NTEventLogAppender.dll using MinGW, place mingw\bin on path for 
Windows or install mingw
+package on other platforms.  Build will execute gcc and windres on Windows and
+i586-mingw32msvc-gcc and i586-mingw32msvc-windres on other platforms.
+
+To build NTEventLogAppender.dll using Microsoft tools, run the appropriate 
vcvars for the
+target platform and specify msbuild as the target on the ant command line.
+
+-->
+
 
 <project name="ntdll" default="build" basedir=".">
    <property name="target.dir" value="target"/>
@@ -33,25 +45,25 @@
   
    <target name="clean" description="Deletes generated files">
         <delete dir="${target.dir}"/>
-   </target>
-
-    <!--
-        Regenerates resource files from EventLogCategories.mc.  Avoids
-        need for Microsoft Platform SDK unless you are modifying 
EventLogCategories.mc
-    -->
-    <target name="mc" description="Update EventLogCategories.rc from .mc">
-        <exec executable="mc">
-            <arg value="-h"/>
-            <arg file="${basedir}"/>
-            <arg value="-r"/>
-            <arg file="${basedir}"/>
-            <arg file="EventLogCategories.mc"/>
-        </exec>
-    </target>
-
+   </target>
 
+    <!--
+        Regenerates resource files from EventLogCategories.mc.  Avoids
+        need for Microsoft Platform SDK unless you are modifying 
EventLogCategories.mc
+    -->
+    <target name="mc" description="Update EventLogCategories.rc from .mc">
+        <exec executable="mc">
+            <arg value="-h"/>
+            <arg file="${basedir}"/>
+            <arg value="-r"/>
+            <arg file="${basedir}"/>
+            <arg file="EventLogCategories.mc"/>
+        </exec>
+    </target>
 
-   <target name="windres" description="Compiles resources">
+
+
+   <target name="windres">
        <condition property="mingw-prefix" value="">
           <os family="windows"/>
        </condition>
@@ -78,7 +90,7 @@
    </target>
 
    <target name="compile" depends="windres" if="do_compile">
-    <fail unless="classes.dir">-Dclasses.dir=/path/to/log4j/classes must be 
specified</fail>
+    <fail unless="classes.dir">-Dclasses.dir=/path/to/log4j/classes must be 
specified</fail>
     <javah 
class="org.apache.log4j.nt.NTEventLogAppender,org.apache.log4j.Priority"
            destdir="${object.dir}"
            classpath="${classes.dir}"/>
@@ -109,7 +121,60 @@
        <echo>${jni.win32.include.dir}/jni_md.h not found, 
NTEventLogAppender.dll build skipped.</echo>
    </target>
 
-   <target name="build" depends="compile, windres-echo, jni_md.h-echo">
+   <target name="build" depends="compile, windres-echo, jni_md.h-echo" 
description="Build with MinGW gcc">
+   </target>
+
+    <target name="rc">
+         <exec executable="rc"
+           dir="${src.dir}"
+           resultproperty="rc_status"
+           failonerror="${failonerror}"
+           failifexecutionfails="${failifexecutionfails}">
+               <arg file="${src.dir}/NTEventLogAppender.rc"/>
+         </exec>
+         <condition property="rc_success">
+          <equals arg1="${rc_status}" arg2="0"/>
+         </condition>
+         <condition property="do_cl">
+         <and>
+                 <isset property="rc_success"/>
+                 <isset property="jni_md.h_available"/>
+             </and>
+         </condition>
+    </target>
+
+    <target name="cl" depends="rc" if="do_cl">
+     <fail unless="classes.dir">-Dclasses.dir=/path/to/log4j/classes must be 
specified</fail>
+     <mkdir dir="${object.dir}"/>
+     <javah 
class="org.apache.log4j.nt.NTEventLogAppender,org.apache.log4j.Priority"
+            destdir="${object.dir}"
+            classpath="${classes.dir}"/>
+
+     <property name="object.location" location="${object.dir}"/>
+     <exec executable="cl" dir="${target.dir}">
+       <arg value="/MT"/>
+       <arg value="/D_JNI_IMPLEMENTATION_"/>
+       <arg value="/O2"/>
+       <arg value="/GR-"/>
+       <arg value="/LD"/>
+       <arg value="/I${jni.win32.include.dir}"/>
+       <arg value="/I${jni.include.dir}"/>
+       <arg value="/I${object.location}"/>
+       <arg value="/I${src.dir}"/>
+       <arg file="${src.dir}/nteventlog.cpp"/>
+       <arg file="${src.dir}/NTEventLogAppender.res"/>
+       <arg file="${src.dir}/NTEventLogAppender.def"/>
+       <arg value="advapi32.lib"/>
+       <arg value="/FeNTEventLogAppender.dll"/>
+     </exec>
+    </target>
+
+    <target name="rc-echo" depends="rc" unless="rc_success">
+     <echo>rc could not be found or failed, NTEventLogAppender.dll build 
skipped.</echo>
+    </target>
+
+
+   <target name="msbuild" depends="cl, rc-echo, jni_md.h-echo" 
description="Build using Microsoft tools">
    </target>
 
 </project>

Modified: logging/log4j/trunk/src/ntdll/nteventlog.cpp
URL: 
http://svn.apache.org/viewvc/logging/log4j/trunk/src/ntdll/nteventlog.cpp?rev=687885&r1=687884&r2=687885&view=diff
==============================================================================
--- logging/log4j/trunk/src/ntdll/nteventlog.cpp (original)
+++ logging/log4j/trunk/src/ntdll/nteventlog.cpp Thu Aug 21 15:33:14 2008
@@ -28,6 +28,8 @@
 #include <jni.h>
 
 
+HINSTANCE gModule = 0;
+
 /*
  * Convert log4j Priority to an EventLog category. Each category is
  * backed by a message resource so that proper category names will
@@ -126,6 +128,17 @@
  */
 JNIEXPORT jint JNICALL 
Java_org_apache_log4j_nt_NTEventLogAppender_registerEventSource(
    JNIEnv *env, jobject java_this, jstring server, jstring source) {
+       return 
Java_org_apache_log4j_nt_NTEventLogAppender_registerEventSource64(
+           env, java_this, server, source);
+}
+
+/*
+ * Class:     org_apache_log4j_nt_NTEventLogAppender
+ * Method:    registerEventSource64
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL 
Java_org_apache_log4j_nt_NTEventLogAppender_registerEventSource64(
+   JNIEnv *env, jobject java_this, jstring server, jstring source) {
   
   jchar *nserver = 0;
   jchar *nsource = 0;
@@ -143,7 +156,7 @@
     nsource[sourceLen] = 0;
   }
   addRegistryInfo((wchar_t*) nsource);
-  jint handle = (jint)RegisterEventSourceW((const wchar_t*) nserver, (const 
wchar_t*) nsource);
+  jlong handle = (jlong)RegisterEventSourceW((const wchar_t*) nserver, (const 
wchar_t*) nsource);
   free(nserver);
   free(nsource);
   return handle;
@@ -156,11 +169,22 @@
  */
 JNIEXPORT void JNICALL Java_org_apache_log4j_nt_NTEventLogAppender_reportEvent(
    JNIEnv *env, jobject java_this, jint handle, jstring jstr, jint priority) {
-  
+  Java_org_apache_log4j_nt_NTEventLogAppender_reportEvent64(
+      env, java_this, handle, jstr, priority);
+}
+
+/*
+ * Class:     org_apache_log4j_nt_NTEventLogAppender
+ * Method:    reportEvent64
+ * Signature: (JLjava/lang/String;I)V
+ */
+JNIEXPORT void JNICALL 
Java_org_apache_log4j_nt_NTEventLogAppender_reportEvent64(
+   JNIEnv *env, jobject java_this, jlong jhandle, jstring jstr, jint priority) 
{
   jboolean localHandle = JNI_FALSE;
+  HANDLE handle = (HANDLE) jhandle;
   if (handle == 0) {
     // Client didn't give us a handle so make a local one.
-    handle = (jint)RegisterEventSourceW(NULL, L"Log4j");
+    handle = RegisterEventSourceW(NULL, L"Log4j");
     localHandle = JNI_TRUE;
   }
   
@@ -174,14 +198,14 @@
   // a message resource which consists of just '%1' which is replaced
   // by the string we just created.
   const DWORD messageID = 0x1000;
-  ReportEventW((HANDLE)handle, getType(priority), 
+  ReportEventW(handle, getType(priority), 
              getCategory(priority), 
              messageID, NULL, 1, 0, (const wchar_t**) &msg, NULL);
   
   free((void *)msg);
   if (localHandle == JNI_TRUE) {
     // Created the handle here so free it here too.
-    DeregisterEventSource((HANDLE)handle);
+    DeregisterEventSource(handle);
   }
   return;
 }
@@ -199,15 +223,31 @@
   DeregisterEventSource((HANDLE)handle);
 }
 
+/*
+ * Class:     org_apache_log4j_nt_NTEventLogAppender
+ * Method:    deregisterEventSource64
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL 
Java_org_apache_log4j_nt_NTEventLogAppender_deregisterEventSource64(
+JNIEnv *env, 
+jobject java_this, 
+jlong handle)
+{
+  DeregisterEventSource((HANDLE)handle);
+}
 
 //
 //  Entry point which registers default event source (Log4j)
 //     when invoked using regsvr32 tool.
 //
 //
-STDAPI __declspec(dllexport) DllRegisterServer(void) {
+extern "C" {
+__declspec(dllexport) HRESULT __stdcall DllRegisterServer(void) {
        HRESULT hr = E_FAIL;
-    HMODULE hmodule = GetModuleHandleW(L"NTEventLogAppender.dll");
+    HMODULE hmodule = gModule;
+    if (hmodule == NULL) {
+        hmodule = GetModuleHandleW(L"NTEventLogAppender.dll");
+    }
     if (hmodule != NULL) {
         wchar_t modpath[_MAX_PATH];
         DWORD modlen = GetModuleFileNameW(hmodule, modpath, _MAX_PATH - 1);
@@ -229,11 +269,11 @@
                                }
                                if(stat == ERROR_SUCCESS) {
                                        DWORD value = 7;
-                                       stat == RegSetValueExW(hkey, 
L"TypesSupported", 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
+                                       stat = RegSetValueExW(hkey, 
L"TypesSupported", 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
                                }
                                if(stat == ERROR_SUCCESS) {
                                        DWORD value = 6;
-                                       stat == RegSetValueExW(hkey, 
L"CategoryCount", 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
+                                       stat = RegSetValueExW(hkey, 
L"CategoryCount", 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
                                }
                                LONG closeStat = RegCloseKey(hkey);
                                if (stat == ERROR_SUCCESS && closeStat == 
ERROR_SUCCESS) {
@@ -251,9 +291,32 @@
 //     when invoked using regsvr32 tool with /u option.
 //
 //
-STDAPI __declspec(dllexport) DllUnregisterServer(void) {
+__declspec(dllexport) HRESULT __stdcall DllUnregisterServer(void) {
        LONG stat = RegDeleteKeyW(HKEY_LOCAL_MACHINE, 
                
L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\Log4j");
        return (stat == ERROR_SUCCESS || stat == ERROR_FILE_NOT_FOUND) ? S_OK : 
E_FAIL;
 }
+
+BOOL APIENTRY DllMain( HMODULE hModule,
+                       DWORD  ul_reason_for_call,
+                       LPVOID lpReserved
+                                        )
+{
+       switch (ul_reason_for_call)
+       {
+       case DLL_PROCESS_ATTACH:
+           gModule = hModule;
+           break;
+       case DLL_PROCESS_DETACH:
+           gModule = 0;
+           break;
+           
+       case DLL_THREAD_ATTACH:
+       case DLL_THREAD_DETACH:
+               break;
+       }
+       return TRUE;
+}
+
+}
 #endif



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to