Shared Memory Pool

Posted on 2006-04-01
Last Modified: 2012-08-13
Hi, i am trying to find out how a Shared Memory Pool works.

1) A driver will be coded in C will read all the I/O values from a I/O device.
2) All the values will be placed in Memory.
3) Clients coded in will access the memory area, get the values and perform what they are supposed to do according to the value.

Is the above possible? If possible i need some ideas on the implementation because i am abit lost... But the above is from my understanding of what a shared Memory pool is and its uses... anyone with another understanding of a shared memory pool are welcome to comment...

Can any apps access any memory location?

Question by:jaxrpc
    LVL 14

    Accepted Solution

    I think the easiest solution would be:

    let your c driver do the I/O stuff.
    Create a c/c++ DLL to read the stuff from your memory and handle the management for your memory and link this to your VB.NET project.

    According to my humble opinion, you cannot, or very hard, do it from VB.NET without the help of unmanaged code.

    LVL 48

    Assisted Solution

    Do you mean memory-mapped file?
    In any case you need to write client code in C. Different drivers require different client code - using CreateFile or Setup SDK functions, ReadFile, WriteFile, DeviceIoControl etc. - this must be written in driver documentation. If you are working together with driver developer, he must know this.
    C/C++ client talks with driver and reads values using functions like DeviceIoControl. Having these values C/C++ can make them available for VB clients. Placing variables to shared memory is possible, but this is not straightforward and requires adding PInvoke code to VB .NET client.
    I think the best way is writing managed C++ wrapper which talks with driver and provides pure .NET interface for VB .NET clients.
    LVL 12

    Assisted Solution

    I considered using a .NET Windows Service using remoting for communication.
    But I think the C code in the driver to call using remoting would be very difficult.

    So I think another means of communication would be better.

    Here's a .NET Windows Service using an memory mapped file for the data and using a TCP network port for communication.

    A .NET Memory-Mapped Cache TcpListener Service
    It's not the best-organized piece of code, but looks workable.
    I haven't looked into this in detail, but I think you could take the client code, put it in it's own DLL, and compile it with a COM-Compatible-Wrapper.  The COM DLL should then be callable from both the C driver and the .NET clients.
    LVL 12

    Expert Comment

    It might be simpler to roll your own using these .NET wrappers for the .NET clients, and just use memory-mapped-file WIN32 API calls directly in the C driver.

    simple library that wraps the Win32 Memory Mapped File services
    LVL 12

    Expert Comment

    Also, here's tutorial on how to create a windows service and add TCP communications to it.
    It's much simpler and clearer that the eggheadcafe example above.

    P.S. A windows service is basically just a program that starts at system startup, and remains running (unless intentionally shut down, or it fails).
    LVL 12

    Expert Comment

    I think I had some good suggestions, as did PockyMaster and AlexFM -- so I suggest splitting the points.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    I'm currently working for a company where I have to upgrade over 50 VB6 programs to VB.NET 2008.  So far I'm about half way through, and I've learned quite a few tricks that drastically improve the performance of VB.NET apps. Because there are a…
    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now