Answer the question
In order to leave comments, you need to log in
How to have a running application in C#?
Such is the situation. There is some application written in Sharpe. And there is me who wants, using the same sharp, to somehow connect to the process of this application and change something in it. There are no sources for this application.
Tell me which way to google?))
Answer the question
In order to leave comments, you need to log in
This is called disassembling (since there are no source codes). And with this style of question, I can answer - you will need to google for a very long time.
Essentially. In the case of Sharp - ReSharper. It will help to restore some of the source codes and the project. I would even say that he restores the entire project.
If you want to get the source of the application, then I advise dotPeek . It can export source codes to the Visual Studio project.
The ability to work with a debugger is very useful. You seem to be doing just that.
If you need to simulate user behavior - press buttons, enter data into fields - then you can get by with WinAPI (get the window handle and send commands via SendMesssage). If you need to change data in memory, then without a debugger you can’t go anywhere.
You can use WinApi to write to process memory. To do this, you need to know the process ID. In my opinion, the most convenient way to do this is knowing the name of the process (the name of the executable file without the EXE extension or path).
public static uint GetProcessID(string name)
{
return (uint)Process.GetProcessesByName(name)[0].Id;
}
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Int32 bInheritHandle, UInt32 dwProcessId);
IntPtr process_handle = OpenProcess(0x001F0FFF,1,process_id);
[DllImport("kernel32.dll")]
public static extern Int32 CloseHandle(IntPtr hObject);
The idea is this: if you have a reference to the AppDomain , you can call your code in it . The problem is how to get the domain of the remote process. This is just what popped up . If I understand you correctly, you need something like this. However, I'm not sure that DoCallback can be called for the domain of another process. And that it is possible to get domains by ProcessID is also not a fact. Alternatives: as already said, SendMessage. Maybe there is something in System.Reflection.Emit.
Here's another article googled, maybe it will be interesting, or maybe it's not quite in the topic. In any case, find a solution - unsubscribe, very interesting!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question