• 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

streetfighter 2

New Member
Joined
Jul 26, 2010
Messages
1,655 (0.33/day)
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.
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.65/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
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

New Member
Joined
Jul 26, 2010
Messages
1,655 (0.33/day)
Location
Philly
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().
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:

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.65/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
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:

streetfighter 2

New Member
Joined
Jul 26, 2010
Messages
1,655 (0.33/day)
Location
Philly
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.
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
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.65/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
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.
 
Top