Ask a questionAsk a question
 

Questionwhich tab belongs to which process

  • Wednesday, November 04, 2009 1:36 AMedjohon Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    hello, When I run iexplore.exe (8.0) it starts two processes, (I know its by design)

    Is there an API that I can call to let me know which one is the recoveryprocess?

    and secondly, lets say I open another tab, now I have 3 processes started, is there an API that will let me know which process each tab belongs to?

    If I do a snapshot of the processlist can I count on the first iexplore.exe returned to always be the "recoveryprocess"?

All Replies

  • Wednesday, November 04, 2009 9:44 PMjeffdav Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    No, there is no API for these things.  Process IDs wrap and are re-used, so you cannot count or ordering information.  

    Why do you need to know?  What is the problem you're trying to solve with this knowledge?  There may be a better way.
  • Thursday, November 05, 2009 12:31 AMedjohon Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I am hooking recv in order to check how one of my servers responds to certain requests.
    Now if I dont know which iexplore.exe I should hook it in, it wont get called... and I dont want to hook all the iexplore processes, only the one
    that I send requests to my server from.

    I came up with something that works most of the time, but it seems that its not 100%
    sometimes I have to hook recv in the recovery process and sometimes in the visible iexplore.exe process.

    I have no idea why this is, but anyway I think the "recovery process" always has a dwExStyle which is 0x180

    BOOL CALLBACK EnumIEProcs(HWND hwnd, LPARAM lParam)
    {
          DWORD pidOut = 0;
          GetWindowThreadProcessId(hwnd,&pidOut);

          if((DWORD)lParam==pidOut) {
                CHAR szTitle[255] = {0};
                GetWindowText(hwnd,szTitle,255);
                _strlwr_s(szTitle);
                if(strstr(szTitle,"windows internet explorer")) {
                      WINDOWINFO windinfo = {0};
                      windinfo.cbSize =
    sizeof(WINDOWINFO);
                      GetWindowInfo(hwnd,&windinfo);
                      //printf("windinfo.dwExStyle = %x",windinfo.dwExStyle);
                      if(windinfo.dwExStyle==0x180) {
                            g_HWND = hwnd;
                            return FALSE;
                      }
                }
          }
          return TRUE;
    }
    get a snapshot... then...
    EnumWindows(EnumIEProcs,(LPARAM)pe32.th32ProcessID);
    ...
    and so on...
    if we get a g_HWND back we know its the HWND to the "recovery process"
    and can then do stuff, like hook recv...

    anyway 9 times out of ten hooking it in the "recovery process" will work, but as I said, I
    have noticed that sometimes the hook needs to be placed in the other iexplore.exe
    process in order to work and I have no idea why...

  • Thursday, November 05, 2009 2:36 AMjeffdav Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    If this is just for debugging purposes, you could just turn off the tab / process separation.   Set the TabProcGrowth key to 0.

    The recovery process may also have a different command line.  You can check with GetCommandLine().