C # LPC/local process call,
Although there are many types of process communication technologies, such as named pipes, anonymous pipelines, serial communication, MSAA,
Memory Sharing, file ing, socket, datagram, message queue, Remoting, WCF, ASM ",
LPC (Local Procedure Call) is a process Communication Technology and cross-origin control technology.
Similar to RPC (Remote Procedure Call), this function is supported in. NET.
For our C/S developers, WCF is not a commendable technology. First, it is the HTTP protocol.
Communication, the underlying Socket/TCP can be understood as RPC extension, while WCF has a way to modify App. Config
The BaseAddress in is Net. Tcp: // LocalHost: Port, but it is used for TCP communication. I don't know what this means,
Even if RPC supports IPC and TCP, cross-domain operations can be faster, but most of the C/S software is a standalone version.
For cross-computer operations, RPC/IPC will be good, but I do not have much affection for the technology of WCF,
The following is a cross-region LPC:
Assume that a.exeis mapped to the.exe ing object through the lpcmethod.
Then, B .exe directly starts to operate B .exe. when the cross-domain access to a.exeis called, the region will be in a.exe.
Processing is completed, and the result is transferred to B .exe.
There is no perfect cross-domain operating technology in the world, but at present it is enough to expect too much
The code below is mainly for software design.
Process Diagram of an LPC application (entertainment and non-commercial) code according to the modified part of the name
For a Themyth Chrome application being debugged, check whether the task manager is very curious.
For example, vshost32-clr2.exe consumes a small amount of memory. This software splits WebBrowser
Exclusive, such as Google Chrome & Internet Explorer 10
The WebBrowser service process (background) and WebBrowser management are divided into two parts.
The process (front-end), however, has become a consensus that the "back-end" and "front-end" can be integrated into an execution file.
Look at the excellent multi-label Browser
However, the. Net WebBrowser is still very user-friendly. It encapsulates a large number of malicious code as needed normally.
Support for customizing JScript Extern for WebBrowser, and remove the border from WebBrowser must be
WebBrowser is connected to the IDocHostUIHandler interface, which was previously specially done once. I almost didn't cry.
The default flat style is WebBrowser. ObjectForScripting = custom JScript Extern, which is convenient.
Okay, it's too far away.
One disadvantage of MSAA/LPC is that it only applies to form programs. At first, it mainly helps with disability and weakness.
The code is used to obtain the WebRemoteObject mapped by this process through LPC.
Can be directly converted to WebRemoteObject, and then directly operate, but in this process only test LPC
Use Mutex to check whether the application is running. If the application is not running, run MainForm.
We can see that MainForm maps objects through LPC. If the App is running
Use FindWindow to find the window handle with the title MainForm.
You can call this operation to obtain the window from the left-side navigation pane.
But we can see that the object of the COM type is no longer a WebRemoteObject.
Important: if the system does not register the object type you need to write cross-origin, another process will get
The class and interface cannot be converted. A simple principle is that process B does not know the objects mapped to process.
The specific type, so it regards the object as an IDispatch/IUnknown (is it true?
Back to the C ++ era) Haha, if you write an independent COM library and register it in the system, then
Process B knows what type it is, but it does not need to get its value. How can this problem be solved? Reflection
I specially wrote a CComObject class to solve this problem mainly by extension, but I suggest you
Write a Wrapper class, which can be understood as mutual Call Protocol
There is a WebRemoteObjectWrapper class, which mentioned the mutual call protocol.
It is not hard to write. On the contrary, it is easy to ignore complicated operations and does not need to register with the system.
LPC applications are easy to implement without writing too much code,
However, you should compile and debug the project before compiling it.
Find the project execution file in the directory, and then you can see the effect of cross-origin operations at once.
Example source code: http://share.weiyun.com/3102c171964c0693cf0f3a2f9906f53b
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.