1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Best IPC mechansim for simple x86-x64 communication

Discussion in 'Programming & Webmastering' started by streetfighter 2, Jan 15, 2011.

  1. streetfighter 2

    streetfighter 2 New Member

    Joined:
    Jul 26, 2010
    Messages:
    1,655 (0.66/day)
    Thanks Received:
    732
    Location:
    Philly
    I'm writing a program that needs to query all the processes on a x64 vista/7 OS. Unfortunately that means I need a 32-bit and a 64-bit executable. I want the vast majority of the code to be in the 64-bit executable but I still need some way of communicating with the 32-bit executable. I'm only transferring a small amount of simple variable data (like process ID or image name) to the main executable so I don't need a robust IPC mechanism.

    I've looked at the MSDN page on IPC and I get the feeling I'm in over my head. I've used named pipes in the past (because I'm familiar with them on linux) but I'm not sure if it's the best method.

    Any help would be appreciated! :)

    PS. If it matters I'm probably going to write this in C++, but I'm very flexible.
     
  2. W1zzard

    W1zzard Administrator Staff Member

    Joined:
    May 14, 2004
    Messages:
    16,597 (3.48/day)
    Thanks Received:
    17,131
    Last edited: Jan 15, 2011
    streetfighter 2 says thanks.
    10 Year Member at TPU
  3. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    19,909 (6.32/day)
    Thanks Received:
    9,177
    Location:
    IA, USA
    I'd recommend .NET Framework and build the executable for "Any CPU." It runs at x86 on x86 and AMD64 on x86-64. One executable for both platforms.

    PID and process name are easily accessible via System.Diagnostics.Process.GetProcesses().
     
    streetfighter 2 says thanks.
    Crunching for Team TPU
  4. streetfighter 2

    streetfighter 2 New Member

    Joined:
    Jul 26, 2010
    Messages:
    1,655 (0.66/day)
    Thanks Received:
    732
    Location:
    Philly
    I probably should have mentioned that whatever language I use I wasn't planning on using .NET. . . However given the strengths of .NET when working in a mixed 32/64 environment, I may have to change my mind. :)

    I was looking at MSDN and it looks like the core function of my program could be reduced to 30 or so lines of code in .NET, as opposed to 100+ in standard C++. Damn you .NET! :laugh:

    I'll probably make a prototype of my program in .NET and standard C++ (using shared memory and separate executables) just to see which is faster and lighter.

    I did consider that briefly when I was writing an app some time ago, but after running some tests I was less than impressed by the performance using the WMI. Perhaps it's time for another try? :)
     
    Last edited: Jan 15, 2011
  5. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    19,909 (6.32/day)
    Thanks Received:
    9,177
    Location:
    IA, USA
    FYI, when using processes, there is a pretty big performance penalty when querying the Process.MainModule. If you can, try to use the Process information from the Process[] array. There's a lot there (including .Id and .ProcessName) so hopefully you won't have to get access the module.

    Also note that GetProcesses() returns some virtual processes like "System Idle Processes." You may have to add some code which ignores those (if memory serves, their .ProcessName starts with $ which is unique to them).


    Most inter-process communication is done via the process handle (.Handle).


    I should also note that "Express" versions of Visual Studio are x86 only. You need the full-fledged Visual Studio in order to compile "Any CPU," "IA64," and "x64" binaries.
     
    Last edited: Jan 15, 2011
    streetfighter 2 says thanks.
    Crunching for Team TPU
  6. streetfighter 2

    streetfighter 2 New Member

    Joined:
    Jul 26, 2010
    Messages:
    1,655 (0.66/day)
    Thanks Received:
    732
    Location:
    Philly
    I don't really like Visual Studio anyway, so I was planning on trying my hand at Mono and it's C# compiler. I don't know about Mono's build options.

    On the other hand I've read that there are actually a couple ways to trick VS:Express into a different build mode. . . Though I don't mean to switch this thread to a discussion of 32-64 IDEs and compilers. :D
     
  7. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    19,909 (6.32/day)
    Thanks Received:
    9,177
    Location:
    IA, USA
    I haven't done much work with Mono. All I know is that in order for one of my apps to work on Mono, I had to change all the file paths from \ to /. That's all it really took to make it work in Windows and Mono.
     
    Crunching for Team TPU

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)