Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7047963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:50:04+00:00 2026-05-28T02:50:04+00:00

Here’s a scenario I’m exploring for a plugin framework: A third party plugin developer

  • 0

Here’s a scenario I’m exploring for a plugin framework:

A third party plugin developer designs a DLL with a known entry point and arbitrary parameters. They also provide details of the entry point and parameters in an XML file and provide data which they’ll be called back with by my program when the plugin is invoked. They’ll be alble to use a set of extensible variables in the XML which my program will expand and pass back to them through the parameters they specify.

I know that in win32 I can use LoadLibrary/GetProcAddress to get hold of the function they define. What I’m less clear about is whether I can dynamically generate a function specification from their defined parameters which I can use to call them back with. Anyone know if this is possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:50:05+00:00Added an answer on May 28, 2026 at 2:50 am

    What I decided to do is to simply make the plugins accept a simple interface of:

    DWORD func ( LPARAM pBuf, DWORD size );
    

    This would allow the user to specify their parameters in the XML and then define a structure which they expect me to pass them, e.g.

    typedef struct
    {
        int a;
        float b;
        double c;
        wchar_t * d;
    } test1;
    

    When they get this message from me, they can check the size before using the buffer to ensure that the XML and the structure match.

    As I parse the XML, I use this class with template methods to dynamically construct the object:

    class DynamicStructure
    {
    public:
    
        template <typename T>
        void addField(const T & field)
        {
            m_mapPtrSize.push_back(std::make_pair(reinterpret_cast<const LPARAM>(&field), sizeof(T)));
        }
    
        DWORD getSize()
        {
            //
            // Work out the combined size of all the fields
            DWORD sSize = 0;
            for ( auto it = m_mapPtrSize.cbegin(); it != m_mapPtrSize.cend(); it++ )
            {
                sSize += it->second;
            }
    
            return sSize;
        }
    
        LPARAM getBuffer()
        {
            // Create a buffer big enough for all the fields
            //
            LPARAM pBuf = reinterpret_cast<LPARAM> (new (std::nothrow) BYTE[getSize()]);
    
            if (pBuf == NULL)
                return NULL;
    
            DWORD offset = 0;
            for ( auto it = m_mapPtrSize.cbegin(); it != m_mapPtrSize.cend(); it++ )
            {
                // Copy the fields one at a time, offsetting into the buffer
                //
                memcpy( (void*) (pBuf + offset), (const void*) it->first, it->second);
                offset += it->second;
            }
    
            return pBuf;
        }
    
    protected:
    private:
        std::vector<std::pair<const LPARAM, DWORD>> m_mapPtrSize;
    };
    

    This allows me to perform the following kind of operation as I parse the XML:

    DynamicStructure dynStruct;
    int a = 1;
    float b = 2.3f;
    double c = 3.5;
    wchar_t * d = L"bob";
    
    dynStruct.addField(a);
    dynStruct.addField(b);
    dynStruct.addField(c);
    dynStruct.addField(d);
    
    // Test - does the dymanic structure match the user's structure?
    LPARAM pBuf = dynStruct.getBuffer();
    test1 * pTest1 = (test1 *) pBuf;
    
    std::wcout << pTest1->a << " " << pTest1->b << " " << pTest1->c << " " << pTest1->d << std::endl;
    

    It’s not perfect, and it’s a bit old school, but at least it’s simple and provides a reasonable level of safety.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my scenario: <!-- Normal Control --> <div class=required> <label for=address1>Address line 1</label> <input
Here's my scenario - I have an SSIS job that depends on another prior
Here is the scenario: I'm writing an app that will watch for any changes
here is the scenario 1: user starts to type some word, autocomplete engine shows
Here's my proposed (very simplified to illustrate the problem space) design for a C#
Here the total height of all <div> 's are 900 pixels, but the jQuery
Here is a complete example. I want to forbid using A::set from objects casted
Here's the deal: I'm in the process of planning a mid-sized business application that
Here's what I want to do: Given a table PeopleOutfit (id int primary key,
Here's the method. I want to know if I am violating any best practices

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.