Shared Named Memory Help menu

Shout-Out

User Tag List

Results 1 to 4 of 4
  1. #1
    Harland's Avatar Member
    Reputation
    8
    Join Date
    Oct 2007
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Shared Named Memory Help

    Hey guys I was wondering if anyone has had experience with using Shared Named Memory for IPC. I'm a little stuck with writing to my shared memory segment between my inject C++ DLL and a C# Controller.

    Lets say in my C# Controller I have a managed data type of float and I want to write that data structure to my shared memory. So I would think I would use the Marshal class to allocate some unmanaged memory. Followed by obtaining a pointer to the newly created memory and using PInvoke to CopyMemory the data structure to my shared memory.

    Unfortunately I have hit a hurdle and think I am going about this the wrong way (ie Using the concept of shared memory incorrectly). Am I suppose to be using serialisation in order to store the data types?

    Another thing I'd like some reassurance on how others use IPC to communicate from their controller to their DLL. Are they simply writing flags from the controller to the DLL to lets say invoke the CTM function? Or have you got some form of interrupt voodoo happening that your DLL can pick up?

    If someone can nudge me in the right direction that would be much appreciated. Any insight provided would be awesome. I feel like I am just bashing my head against a brick wall right now.

    P.S. I am currently am able to read and write Strings to my Shared Named Memory right now. Just it seems to fail if I attempt to write bytes to my memory.

    Code:
    //String to write to managed memory
    string s = "Meow"
    
    IntPtr ptr = Marshal.StringToHGlobalUni(s);
    
    //pBuf is the handle to the shared named memory
    SnausWin32APIs.CopyMemory(pBuf, ptr, 8);
    
    //Free ptr
    Marshal.FreeHGlobal(ptr);

    Shared Named Memory Help
  2. #2
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm pretty sure .NET 3.0 has a class in the Remoting namespace. There's a few articles on MSDN about the named pipes.

    EDIT: Maybe not. Could have sworn I saw something o.O
    Last edited by lanman92; 01-08-2010 at 10:07 PM.

  3. #3
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Harland View Post
    Hey guys I was wondering if anyone has had experience with using Shared Named Memory for IPC. I'm a little stuck with writing to my shared memory segment between my inject C++ DLL and a C# Controller.
    If, as I suspect, you're using a shared mapped memory segment (a bit of the page file swapped into both processes), you'll be much happier simply using unsafe code and pointers on the C# side.

    MUCH happier. Ultimately what you want is the ability to read and write managed data from unmanaged memory, and this is *precisely* what unsafe code is designed to allow you to do easily.

    On the C++ side, there shouldn't be any problems whatsoever, of course.
    Don't believe everything you think.

  4. #4
    Harland's Avatar Member
    Reputation
    8
    Join Date
    Oct 2007
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your reply amadmonk, unsafe code yielded some nice google results to point me in the right direction.

    Yeah the C++ side of things was faultless, just C# was giving me a little grief.

Similar Threads

  1. Topsite name need Help
    By cajkan in forum Community Chat
    Replies: 2
    Last Post: 06-13-2012, 07:55 AM
  2. Can only use 4gb of memory. Help wanted!
    By Freefall552 in forum Hardware
    Replies: 14
    Last Post: 01-10-2012, 10:58 AM
  3. Kicked off of WoW/Account Sharing = Ban Perm? Help me =\
    By General Barcode in forum World of Warcraft General
    Replies: 8
    Last Post: 06-26-2009, 02:54 PM
All times are GMT -5. The time now is 06:46 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search