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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:46:45+00:00 2026-05-24T03:46:45+00:00

Can someone help me to know how can i use dlopen to get handle

  • 0

Can someone help me to know how can i use dlopen to get handle of libc memory allocation functions? Especially, something like searching the libc path and then taking the handle. What modes should be used to invoke dlsym?

Idea is:

  1. Search libc path
  2. Invoke dlopen on it
  3. Use dlsym to access the memory functions (malloc, calloc etc) and
  4. use the functions

Please help me with a code snippet of the above 4 steps.

  • 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-24T03:46:46+00:00Added an answer on May 24, 2026 at 3:46 am

    Here’s a code snippet, HTH

    #include <dlfcn.h>
    #include <stdio.h>
    
    // For LIBC_SO which expands to proper libc name
    #include <gnu/lib-names.h>
    
    int main()
    {  
       void *handle; 
       
       // dlopen will search the path for you
       // LIBC_SO expands to shared library name
       // for libc
       handle = dlopen(LIBC_SO, RTLD_LAZY); 
    
       if(handle){
             void* (*mallocptr)(size_t);
             void (*freeptr)(void*);
    
             // Locate symbols
             *(void**)(&mallocptr) = dlsym(handle, "malloc");
             *(void**)(&freeptr) = dlsym(handle, "free");
             
             if(!mallocptr || !freeptr){
                printf("%s\n", dlerror());
                return 1;
             }
    
             // Allocate and use memory
             char *ptr = (*mallocptr)(4);
             ptr[0] = 'H'; ptr[1] = 'i'; ptr[2] = '\n'; ptr[3] = '\0';
             printf(ptr);
             
             // Free it
             (*freeptr)(ptr);
       }
       else{
          printf("%s\n", dlerror());
          return 1;
       }
       return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just installed jquery-ui-module, but don't know how to use it. Can someone help
I don't know why I can't use the MultivaluedMap here, can someone help. Eclipse
Can someone help me create an index/count button for a UITableView, like this one?
I know LiveKd is a tool to create dumps for analysis. Can someone help
Please can someone help me understand anonymous access in IIS. I know by when
Can someone help me turn the enhanced for loop for(int cell:locationCells) to a regular
Can someone help me figure out an easy way to limit the UITextField range,
Can someone help me identify what the purpose of this unidentified syntax is. It
Can someone help me with this: This is a program to find all the
Can someone help me to find a solution on how to calculate a cubic

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.