Share data between C# and Delphi with madshi IPC

c++ / delphi package - dll injection and api hooking

Re: Share data between C# and Delphi with madshi IPC

Postby madshi » Tue Oct 16, 2018 1:44 pm

Sorry for the late reply. I've tried to download your sample now, but I failed. I'm getting redirected through multiple sites, asked to turn off my ad blocker, asked to allow notification, and still no download link. Could you please use a proper file host? E.g. try mediafire.
madshi
Site Admin
 
Posts: 9821
Joined: Sun Mar 21, 2004 5:25 pm

Re: Share data between C# and Delphi with madshi IPC

Postby ExPx » Tue Oct 16, 2018 1:54 pm

ExPx
 
Posts: 29
Joined: Fri Oct 21, 2016 3:20 pm

Re: Share data between C# and Delphi with madshi IPC

Postby madshi » Tue Oct 16, 2018 2:25 pm

Not sure why, but it seems to work fine here without crashes. Can you double check? Here's my build, compiled with XE8 using madCodeHook v4:

http://madshi.net/IPCCrashTest.rar
madshi
Site Admin
 
Posts: 9821
Joined: Sun Mar 21, 2004 5:25 pm

Re: Share data between C# and Delphi with madshi IPC

Postby ExPx » Tue Oct 16, 2018 2:40 pm

I tested and it seems working very well. I mixed yours and my examples. Your 32bit receiver part works good.
ExPx
 
Posts: 29
Joined: Fri Oct 21, 2016 3:20 pm

Re: Share data between C# and Delphi with madshi IPC

Postby madshi » Tue Oct 16, 2018 2:45 pm

I'm not sure if it's the difference between v3 and v4, or maybe XE2 vs XE8? I think it's more likely v3 vs v4.
madshi
Site Admin
 
Posts: 9821
Joined: Sun Mar 21, 2004 5:25 pm

Re: Share data between C# and Delphi with madshi IPC

Postby madshi » Tue Oct 16, 2018 3:08 pm

I've uploaded XE2 v4 and XE8 v3 builds here, for you to test:

http://madshi.net/IPCCrashTest2.zip
madshi
Site Admin
 
Posts: 9821
Joined: Sun Mar 21, 2004 5:25 pm

Re: Share data between C# and Delphi with madshi IPC

Postby ExPx » Tue Oct 16, 2018 3:22 pm

Company firewall doesnt allow download (virus alert). I will try at home.
ExPx
 
Posts: 29
Joined: Fri Oct 21, 2016 3:20 pm

Re: Share data between C# and Delphi with madshi IPC

Postby ExPx » Tue Oct 16, 2018 6:39 pm

I tried both mine and your demos at home. IPCCrashTestApp XE2 v4 working well. IPCCrashTestApp XE8 v3 crashes like mine.
ExPx
 
Posts: 29
Joined: Fri Oct 21, 2016 3:20 pm

Re: Share data between C# and Delphi with madshi IPC

Postby madshi » Tue Oct 16, 2018 8:32 pm

Oh well, looks like a bug in v3 then, probably... :(
madshi
Site Admin
 
Posts: 9821
Joined: Sun Mar 21, 2004 5:25 pm

Re: Share data between C# and Delphi with madshi IPC

Postby ExPx » Wed Oct 24, 2018 10:01 am

I upgraded to v4 and problem solved.

One more question. How can I use AddAccessForEveryone. Can you provide sample ? I am planning to run this code in delphi service AfterInstall event.
ExPx
 
Posts: 29
Joined: Fri Oct 21, 2016 3:20 pm

Re: Share data between C# and Delphi with madshi IPC

Postby jonny_valentine » Thu Nov 08, 2018 11:39 am

ExPx wrote:Hi madshi,

Any progress for this issue ?


Just to let you know that it is completely possible to use the IPC between (any language) c++ DLL and c# application as i use it already. Its not easy to push callbacks of this nature into c#, you need to be 3l1t3 ;)

There is no bug with the MCH/SendIPC system...
jonny_valentine
 
Posts: 109
Joined: Thu Dec 30, 2004 9:59 pm
Location: UK

Re: Share data between C# and Delphi with madshi IPC

Postby iconic » Thu Nov 08, 2018 9:26 pm

Hmmm after taking a look at the posted code from ExPx for the IPC callback it's using the updated prototype which includes the extra Context pointer parameter. Well, if a user was using MCH v3.x (which he was) with the updated IPC callback prototype from MCH v4.x, this could cause issues. Case example below:

Code: Select all
MCHv3.CreateIpcQueue(IPC_NAME, @Callback);

Code: Select all
MCHv4.Callback(lpName: PChar;
                         lpMessageBuf: PWChar;
                         dwMessageLen: DWORD;
                         lpAnswerBuf: Pointer;
                         dwAnswerLen: DWORD;
                         lpContext: Pointer <--- unexpected);


That's assuming lpContext param addition was specifically introduced in v4 and wasn't used in v3. I'm a 4.x user so I'd have to check the older prototype. The help docs only show the newest/latest (v4.x) ...

--Iconic
iconic
 
Posts: 846
Joined: Wed Jun 08, 2005 5:08 am

Re: Share data between C# and Delphi with madshi IPC

Postby madshi » Tue Nov 13, 2018 5:58 pm

Good catch, iconic! That might explain the problem nicely.

@ExPx, you should not have to call AddAccessForEveryone yourself, CreateIpcQueue already does that for you internally. But anyway, if you want to know how to call it, you can check "InjectService.cpp" in this demo:

http://madshi.net/HookProcessTermination.zip
madshi
Site Admin
 
Posts: 9821
Joined: Sun Mar 21, 2004 5:25 pm

Previous

Return to madCodeHook

Who is online

Users browsing this forum: No registered users and 9 guests