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 8399261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:15:14+00:00 2026-06-09T21:15:14+00:00

Lets say i have the following function in my DLL: void TestFunction(int type, void*

  • 0

Lets say i have the following function in my DLL:

void TestFunction(int type, void* data)

Now that function is called from an application which loads that DLL. The application initializes a structure and sends a pointer to that structure to that function:

SampleStruct strc;
TestFunction(DT_SS, &ss);

So far so good. Now what troubles me is how to replace the strcc variable in memory with another structure. If i do the following in my dll:

SampleStruct dllstrcc;
data = &dllstrcc;

data will now point to the new dllstrcc structure however when it exists the function and the control returns to the application the strc will still point to the first structure. How can i replace the structure of the application with my structure from the dll without assigning each field:

data.vara = dllstrcc.vara;
data.varb = dllstrcc.varb;
data.varc = dllstrcc.varc;
  • 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-06-09T21:15:16+00:00Added an answer on June 9, 2026 at 9:15 pm

    1. The simplest option is to copy the whole struct:

    void TestFunction(int type, void* data) {
        SampleStruct dllstrcc;
        // fill dllstrcc here...
        SampleStruct *p_ret = data;
        *p_ret = dllstrcc;
    }
    

    And call it via

    SampleStruct strcc;
    TestFunction(type, &strcc);
    

    The benefit is that you don’t have to worry about freeing memory, etc.

    2. If you really want to replace the structure of the caller (have a new structure), you can allocate a new structure in the DLL.

    void* TestFunction(int type) {
        SampleStruct* pdllstrcc = new SampleStruct();
        return pdllstrcc;
    }
    

    (I’ll return the new structure because it’s much easier, but you could pass it out through a parameter if you need to by using void** data.)

    You can call the function like:

    SampleStruct *strcc = TestFunction(type);
    // do something with the struct
    delete strcc;
    

    Don’t forget to delete the pointer, otherwise you’ll leak memory. You should explicitly decide who’s responsibility it is to free the memory, the caller’s or the DLL’s.

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

Sidebar

Related Questions

Lets say I have the following code that returns number of anchor elements on
Lets say I have the following code. double *return_array(void) { double foo[2]; foo[0] =
The scenario is the following: Lets say I have this application App that depends
Lets say we have the following: create view view_1 as ( select key, data
Lets say I have the following two PHP arrays that contain integers: $foo =
Lets say i have the following code private Func<T> _method; public void SetExecutableMethod<T>(Func<T> methodParam)
Lets say, If I have a situation like the following. Type somethingType = b.GetType();
Lets say we have following vector: data=a=[2.3 3.2 4.1 6.2 7.3 6.4 5.5 4.3
Lets say i have the following code. class A { function one() { return
Lets say i have a table that has the following field names 'id' 'likes'

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.