views:

207

answers:

2

We have two services: one service is 32-bit (process1) and the other is 64-bit (process2). We have code that process1 is using to check if process2 is running: HANDLE hProcess; RESET_WIN_ERRNO;

hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ProcessId);
if (hProcess == NULL) {
    os_SetWinErr(err_code);
    return FALSE;
} 
CloseHandle(hProcess);
return TRUE;

This code works fine in Windows server 2003 but doesn't work in Windows server 2008. Any ideas?

I read about Session0 for services that was introduced in win2008 but in our case both are services (unless Microsoft hates java so much that moves it to Session1), so there shouldn't be any access problems.

I found this thread: http://social.msdn.microsoft.com/forums/en-US/winserver2008appcompatabilityandcertification/thread/c7d7e3fe-f8e5-49c3-a16f-8e3dec5e8cf8/ which states that 32-bit process cannot access 64-bit process anymore. What can be done here?

A: 

may be, this is because 32bit process handle is 4bytes(sizeof pointer), 64bit process handle is 8bytes(sizeof pointer?)? if yes, 32bit process handle may not hold 64bit process handle.

http://social.msdn.microsoft.com/Forums/en-US/wlsearchdev/thread/9282b719-fc63-482f-bf42-398e8f03238a hope this helps

calvin
Thanks, I'll try to use EnumProcessModulesEx instead
Anton Kagan
This can't be the answer -- handles are essentially the same values regardless of whether the process is 32-bit or 64-bit. I've disassembled parts of WOW64, and the conversion from a 32-bit WOW64 handle to a full 64-bit handle is just a sign-extension.
Aaron Klotz
A: 

Write a 64-bit helper program that will do the check using that old code and return the result as an exit code. Run this program with CreateProcess() from your 32-bit program.

sharptooth
I think helper program would fail as well because it will run in Session1 from which Session0 is inaccessible. At least I understand it so from Microsoft documentation.
Anton Kagan