Page 2 of 2

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

PostPosted: Tue Oct 16, 2018 1:44 pm
by madshi
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.

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

PostPosted: Tue Oct 16, 2018 1:54 pm
by ExPx

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

PostPosted: Tue Oct 16, 2018 2:25 pm
by madshi
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

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

PostPosted: Tue Oct 16, 2018 2:40 pm
by ExPx
I tested and it seems working very well. I mixed yours and my examples. Your 32bit receiver part works good.

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

PostPosted: Tue Oct 16, 2018 2:45 pm
by madshi
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.

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

PostPosted: Tue Oct 16, 2018 3:08 pm
by madshi
I've uploaded XE2 v4 and XE8 v3 builds here, for you to test:

http://madshi.net/IPCCrashTest2.zip

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

PostPosted: Tue Oct 16, 2018 3:22 pm
by ExPx
Company firewall doesnt allow download (virus alert). I will try at home.

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

PostPosted: Tue Oct 16, 2018 6:39 pm
by ExPx
I tried both mine and your demos at home. IPCCrashTestApp XE2 v4 working well. IPCCrashTestApp XE8 v3 crashes like mine.

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

PostPosted: Tue Oct 16, 2018 8:32 pm
by madshi
Oh well, looks like a bug in v3 then, probably... :(

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

PostPosted: Wed Oct 24, 2018 10:01 am
by ExPx
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.

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

PostPosted: Thu Nov 08, 2018 11:39 am
by jonny_valentine
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...

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

PostPosted: Thu Nov 08, 2018 9:26 pm
by iconic
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

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

PostPosted: Tue Nov 13, 2018 5:58 pm
by madshi
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