Lionel Ulmer lionel.ulmer@free.fr writes:
I have actually no idea what exactly is what Windows is doing there, but this attached patch seems to do the trick. I have no idea if it's correct though (as I do not know if what GetModuleHandle returns is really the same thing as what SetWindowsHookEx expects as an HINSTANCE input).
This doesn't look right, it doesn't make sense to create a system-wide hook without an instance, since in that case there is no way to call the function in other processes. This requires more investigation to find out exactly what Windows does in this case.
On Mon, Jun 14, 2004 at 12:58:55PM -0700, Alexandre Julliard wrote:
This doesn't look right, it doesn't make sense to create a system-wide hook without an instance, since in that case there is no way to call the function in other processes. This requires more investigation to find out exactly what Windows does in this case.
Well, this is why I put fix in quotes as I did not really understood what I was doing.
Anyway, what I know is that the application explicitely puts the NULL parameter, so it's not a bug upstream. So either it's something that worked on Windows95 and not anymore (as the application is quite old) or a problem in Wine.
I will try to run this application on my Win2K box to see if it works (or write a test to see if the call fails or not). I will alas not be able to test much more as I do not know th difference between a system-wide hook and another sort of hook :-)
On the other hand, I thought that as my patch called GetModuleHandle(NULL) the hook would not have been system-wide, but only application wide as I would set the parameter with the handle of the application.
Lionel
Lionel Ulmer lionel.ulmer@free.fr writes:
Anyway, what I know is that the application explicitely puts the NULL parameter, so it's not a bug upstream. So either it's something that worked on Windows95 and not anymore (as the application is quite old) or a problem in Wine.
I will try to run this application on my Win2K box to see if it works (or write a test to see if the call fails or not). I will alas not be able to test much more as I do not know th difference between a system-wide hook and another sort of hook :-)
A system-wide hook is called for all threads, as opposed to a thread-local hook that only runs in the specified thread. A system-wide hook needs a module handle because it may run in any process context, so we need a way to load the proper dll in the address space of the target process.
It may be that when the module handle is NULL Win95 falls back to a thread-local hook, or does some other strange magic; NT refuses to set a system-wide hook with a NULL module, so I'd expect your app to fail on NT (except if it does a version check, in which case it should run on Wine too if you set the Windows version to NT).
On Mon, Jun 14, 2004 at 04:30:28PM -0700, Alexandre Julliard wrote:
It may be that when the module handle is NULL Win95 falls back to a thread-local hook, or does some other strange magic; NT refuses to set a system-wide hook with a NULL module, so I'd expect your app to fail on NT (except if it does a version check, in which case it should run on Wine too if you set the Windows version to NT).
I just checked on my version of Win2K Pro and the application fails to start there too. If someone could check with XP (maybe it has some funky 'old application detection' mode to cope for that), it's the demo for Theme Hospital that can be downloaded there:
ftp://ftp.ea.com/pub/archive/bullfrog/demos/t_hospital/hospital.zip
Just try to run 'hosp95.exe' and if the application just starts and exists right away, you will have the bug.
So now we have two choices: either say 'well, this is a broken application, it does not run at all on modern Windows OSes' or add some special case when we set Wine's version to be 'win95' or 'win98' (a bit like we already do on instruction emulation needed by old games like TombRaider 2).
As to how to progress from there, I am at a loss :-)
Lionel
Lionel Ulmer lionel.ulmer@free.fr writes:
So now we have two choices: either say 'well, this is a broken application, it does not run at all on modern Windows OSes' or add some special case when we set Wine's version to be 'win95' or 'win98' (a bit like we already do on instruction emulation needed by old games like TombRaider 2).
There's probably no need to add a special case, we can simply add the win95 behavior. The question is what that behavior is supposed to be; in the current design a NULL instance is meaningless.