|
From: Richard L. <ric...@ms...> - 2004-03-01 19:55:30
|
Leif,
Thanks again for your very informative response. The custom dll, that
would have been the calling code would have taken the return value,
which is usually regarded as 0 being false and any other value as true,
and actually "cast/convert" the response and use it as if it were an
int. But from what I'm reading from your response, this might be a
little too much for myself to do. But maybe I can work around this
constraint.
This brings me to my next question. If the native code currently
returns a BOOL, is there anyway that the java code can return a true or
false, that way the calling native code will forward that response on?
Richard.
Leif Mortenson wrote:
> Richard,
> I am confused. If I understand correctly then what you are saying does not
> appear to be supported by the Windows API.
>
> It would be possible for the WrapperListener.controlEvent method to return
> an integer rather than a boolean. This would be difficult as it would break
> things for the user base. But it is technically possible. The problem is
> what to do with that code once it has been returned to the native JNI
> library.
>
> This is complicated by what follows, but normally the controlEvent would be
> called from within a Handler callback function registered with the Windows
> SetConsoleCtrlHandler function. This API declares that the handler
> function should return a BOOL, not an int. That means that the calling
> code would interpret 0 as FALSE and anything else as TRUE. I don't see
> how returning an integer code could possibly work?
>
> Now. The problem is that the above call thread is not the way things are
> actually implemented. For some reason I was finding that various versions
> of the JVM liked to crash if a JNI call was made into the JVM from within
> a Ctrl Handler. To work around this, the handler will simply store its last
> known event code. The JVM then polls that code for a value to pass to the
> WrapperListener.controlEvent. User code should never notice a
> difference as signals are never fired at very high rates. The problem is
> that as things are currently implemented, it is not possible to return even
> the BOOL return value. Rather, the WrapperManager java code takes
> responsibility of handling things like CTRL-C events. If the user code
> chose not to handle the event then the WrapperManager does so.
>
> Is this what you are asking?
>
> If all you want to do is be able to pass user defined events to the Wrapper
> and thus the JVM, then the Wrapper should handle that as is. Any user
> defined signals should be passed right into the JVM via the
> WrapperListener.controlEvent method.
>
> Cheers,
> Leif
>
> Richard Luong wrote:
>
>
>>Leif,
>>
>>Thanks for your response. We have implemented a custom login dll that
>>hooks into the windows system. It will send the service a system
>>event. The service will then "respond" back to the the custom dll with
>>a custom code. Thereby allowing pseudo-communication between the java
>>thread being run as a service and the custom windows login dll.
>>
>>Is that not possible with the current code? If not, do you think it
>>would be a hard thing for myself to implement? You are more
>>knowledgable in this topic than I am. But is it possible for me to
>>edit the contolEvent method to return back an integer to the call
>>native code? I don't want to waste time coding something that will not
>>work. Is it possible for a java method to return an integer in JNI?
>>Thanks for your help. This seems like a great product and I really
>>hope I can use it.
>>
>>Richard.
>>
>>
>>
>>>From: Leif Mortenson <le...@ta...>
>>>Reply-To: wra...@li...
>>>To: wra...@li...
>>>Subject: Re: [Wrapper-user] How to catch other system events
>>>Date: Sun, 29 Feb 2004 22:05:46 +0900
>>>
>>>Richard,
>>>The wrapperConsoleHandler function is simply a callback registered
>>>with the
>>>Windows SetConsoleCtrlHandler function. The handler actually returns
>>>a BOOL.
>>>Even if the code allowed you to return a custom code, the Windows API
>>>would
>>>not know what to do with it. Am I missing something?
>>>| |
>>>Cheers,
>>>Leif
>>>
>>>Richard Luong wrote:
>>>
>>>
>>>>Leif,
>>>>
>>>>Thanks for your response. Sorry my response is somewhat late,
>>>>however this project's priority was shifted around for me.
>>>>
>>>>You are correct in that Windows doesn't throw any signal for a use
>>>>login. What I have is a dll, that hooks onto the windows login
>>>>service and basically sends my java thread custom signals. My thread
>>>>will then return an integer as a response. At least that's the plan.
>>>>
>>>>My question is, how do I reply to a system event? I see from your
>>>>code sample below, that your wrapperConsoleHandler returns an int.
>>>>And that int is true. That method then passes it to the JVM's
>>>>controlEvent method, which returns void. Is there anyway that I can
>>>>return my own custom code? Thanks.
>>>>
>>>>Richard.
>>>>
>>>>
>>>>>Subject:
>>>>>Re: [Wrapper-user] How to catch other system events
>>>>>From:
>>>>>Leif Mortenson <le...@ta...>
>>>>>Date:
>>>>>Thu, 08 Jan 2004 18:59:21 +0900
>>>>>To:
>>>>>wra...@li...
>>>>>
>>>>>To:
>>>>>wra...@li...
>>>>>
>>>>>
>>>>>Richard,
>>>>>Sorry I never answered you did I.
>>>>>
>>>>>The Wrapper currently catches system events in the native code,
>>>>>Wrapper.DLL. It is taking any signal except the CTRL_BREAK_EVENT,
>>>>>which
>>>>>is used to generate thread dumps.
>>>>>What is the actual system signal that your card is throwing? Normally
>>>>>windows does not throw any signals that I know of when a user logs
>>>>>in. I am
>>>>>interesting in finding out how your card works because I have been
>>>>>looking
>>>>>for a nice clean way of telling when a user logs on for a while.
>>>>>The next
>>>>>version of the Wrapper allows you to poll for this information, but
>>>>>there is
>>>>>no signal that I could find that is fired when a user logs on to a
>>>>>Windows system.
>>>>>
>>>>>Here is the native code that parses the signals. Note that I am
>>>>>passing any
>>>>>unknown signals off to the JVM as well so the controlEvent method
>>>>>of your
>>>>>WrapperListener should get them if they are thrown.
>>>>>
>>>>>---
>>>>>int wrapperConsoleHandler(int key) {
>>>>>int event;
>>>>>
>>>>>/* Call the control callback in the java code */
>>>>>switch(key) {
>>>>>case CTRL_C_EVENT:
>>>>>event =
>>>>>org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_C_EVENT;
>>>>>break;
>>>>>case CTRL_BREAK_EVENT:
>>>>>/* This is a request to do a thread dump. Let the JVM handle this. */
>>>>>return FALSE;
>>>>>case CTRL_CLOSE_EVENT:
>>>>>event =
>>>>>org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_CLOSE_EVENT;
>>>>>break;
>>>>>case CTRL_LOGOFF_EVENT:
>>>>>event =
>>>>>org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_LOGOFF_EVENT;
>>>>>break;
>>>>>case CTRL_SHUTDOWN_EVENT:
>>>>>event =
>>>>>org_tanukisoftware_wrapper_WrapperManager_WRAPPER_CTRL_SHUTDOWN_EVENT;
>>>>>break;
>>>>>default:
>>>>>event = key;
>>>>>}
>>>>>if (wrapperJNIDebugging) {
>>>>>printf("Got Control Signal %d->%d\n", key, event);
>>>>>flushall();
>>>>>}
>>>>>
>>>>>wrapperJNIHandleSignal(event);
>>>>>
>>>>>if (wrapperJNIDebugging) {
>>>>>printf("Handled signal\n");
>>>>>flushall();
>>>>>}
>>>>>
>>>>>return TRUE; /* We handled the event. */
>>>>>}
>>>>>---
>>>>>
>>>>>Please most back with as much info as you can make available even
>>>>>if you
>>>>>get this working.
>>>>>
>>>>>Cheers,
>>>>>Leif
>>>>>
>>>>>Richard Luong wrote:
>>>>>
>>>>>
>>>>>
>>>>>>I want to hook onto the Windows Login (Gina.dll) so that I can login
>>>>>>through an ID card. I can do the JNI stuff to talk from Java to the C
>>>>>>dll. But I would like the C code to be able to talk back to the Java
>>>>>>code through throwing events to my NT Service.
>>>>>>
>>>>>>My question is, does the Java Service Wrapper catch all events and
>>>>>>pass them on? If that's so, then problem solved.
>>>>>>
>>>>>>If not, does it only pass on specific control events such as windows
>>>>>>logoff, shutdown and ctr+C ?
>>>>>>
>>>>>>If so, can I modify the code to pass on all events? I know that I
>>>>>>will
>>>>>>have to use Integration Method #3, which is not a problem for me.
>>>>>>However, any pointers to the code that is catching and possibly
>>>>>>ignoring/passing on events would be helpful.
>>>>>>
>>>>>>Thanks.
>>>>>
>>>>>
>
>
>
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now!
> http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
> _______________________________________________
> Wrapper-user mailing list
> Wra...@li...
> https://lists.sourceforge.net/lists/listinfo/wrapper-user
>
> .
>
|