Advertisement

how to comunicate with diffrent exe files?

Started by March 19, 2015 12:23 AM
12 comments, last by hplus0603 9 years, 8 months ago

hi.

im working on a program that uses other program for process data and it has many different processes. i think my best choice is to open the program in my code and send my data to it and receive data from it and after that close that program.

is this really possible? how can i really do that? in the end i have to say i wrote that other program and i know the code. i use c# winform and unity c# for my comunicationg programs

thank you for helping

You are going to have to give context.

#1: Why can’t you link to the libraries of the other process and keep them all in a single process? Did you not write it/do you not have access to the source code?

#2: Why can’t you write your data to a file, execute the other process with a command-line telling it where your data is and what to do with it, and have the other process write the result to a file which you can then load? Are there restrictions on how the other process has to get and output data?

#3: If nothing else works you can always use ::ReadProcessMemory() to get the result from the other’s RAM, ::WriteProcessMemory() to send your input data (not necessarily in this order), and ::CreateRemoteThread() to call a function in the other process to make it start processing the data. This is clearly a hack and is very advanced, and obviously only a last resort.

You didn’t give any context what-so-ever so there is really no answer to give. Are both processes your own making? If it is not your process, does it have command-line options? Does it already have to be running or can an instance of it be started when you need (and fed a command line)?

Need more information.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Advertisement

Take a look at the Win32 functions CreateProcess, OpenProcess, ReadProcessMemory and TerminateProcess. EDIT: As L.Spiro mentions, it's not entirely clear how you want to communicate with the other processes, but a combination of the above functions should give you a start.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

You might also want to look into shared memory using memory mapped files, a quick look on Google returned this library that can hook into C# (since the post was tagged with C#). There are other IPC options you can use that may be more in line with you're looking for but, as stated, without context it's hard to give a clear answer.

Hope that helps!

As mentioned above - IPC, or "inter-process communication", is a good search term for ways to communicate between different exes.

Last time I needed this in C#, I used Win32 named pipes.

well. thank you for answers. more explanation is:

its an mmo game that is made by unity. the server when the game ran should the positions of objects are right or not base of physics. server is winform but unity exe should check the result of physics.

Advertisement
I really don't understand the relationship between these processes. Is the server a Unity game or not? It sounds like you have some kind of custom server, and then you want Unity to connect as a client and see the output?

server is winform


My brain just died a little.

Sean Middleditch – Game Systems Engineer – Join my team!

Is there a reason you can't just open sockets at 127.0.0.1 and transfer data that way? It's not as efficient as shared memory but it's much easier to work with, there are cross-platform libraries for sockets, and for 127.0.0.1 I assume that the kernel is optimized enough to not go down all the way to the IP stack before noticing that the packets are for itself.

Shared memory is more efficient but it puts the burden of creating a communication protocol and synchronizing memory reads and writes on your shoulders. So I hope you really need the performance gain if you go that way. It's also less flexible since you can't put the server on a remote machine.


really don't understand the relationship between these processes. Is the server a Unity game or not? It sounds like you have some kind of custom server, and then you want Unity to connect as a client and see the output?


moeen k, on 18 Mar 2015 - 6:51 PM, said:

server is winform


My brain just died a little.

maybe its a little confusing or i explained confusing but the game uses c# .net sockets. the game doesnt need to send and receive data in every frame. so for simplicity its winform. but in some port player starts the game and data is initialised from database. other instance should run on server. the input works compeletely on client but client sends input to server and server runs the game seperately for right data and after end server should chek the result. i think it was the best way we could impelement it

Moving to Multiplayer & Networking Programming.

(That’s what I would have said if I were a moderator.)

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

This topic is closed to new replies.

Advertisement