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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:27:33+00:00 2026-05-28T16:27:33+00:00

What is the difference between memory indirect call and register indirect call? I’m trying

  • 0

What is the difference between memory indirect call and register indirect call?

I’m trying to learn something about linux rootkit detection, how can I recognize such calls in disassembled memory? How do they look in C language before compiling?

  • 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-28T16:27:34+00:00Added an answer on May 28, 2026 at 4:27 pm

    Memory indirect call is a call which takes the address of the callee from the memory and register indirect call takes the address from the register accordingly.

    Implementation of calls is very dependent on the architecture and compiler used. On x86, both memory and register calls are possible, so it’s up to compiler to choose what’s optimal.

    Take a look on a simple test:

    #include "stdlib.h"
    #include "stdio.h"
    #include "time.h"
    
    void example_fun(int param)
    {
        printf("%d\n", param);
    }
    
    void fn1(void)
    {
        printf("fn1\n");
    }
    
    void fn2(void)
    {
        printf("fn2\n");
    }
    
    typedef void (*fn)(void);
    
    int main(void)
    {
        void (*fp) (int) = &example_fun;
        int c;
        fn fn_arr[] = {&fn1, &fn2};
    
        (*fp)(2);
        srand(time(NULL));
        c = rand() / (RAND_MAX / 2);
        switch (c)
        {
            case 0: (*(fn_arr[0]))(); break;
            case 1: (*(fn_arr[1]))(); break;
            default: (*fp)(1);
        }
    }
    

    The generated assembly is (gcc 4.6.1 w/o any optimizations):

        .file   "indirect.c"
        .section    .rodata
    .LC0:
        .string "%d\n"
        .text
        .globl  example_fun
        .type   example_fun, @function
    example_fun:
    .LFB0:
        .cfi_startproc
        pushl   %ebp
        .cfi_def_cfa_offset 8
        .cfi_offset 5, -8
        movl    %esp, %ebp
        .cfi_def_cfa_register 5
        subl    $24, %esp
        movl    $.LC0, %eax
        movl    8(%ebp), %edx
        movl    %edx, 4(%esp)
        movl    %eax, (%esp)
        call    printf
        leave
        .cfi_restore 5
        .cfi_def_cfa 4, 4
        ret
        .cfi_endproc
    .LFE0:
        .size   example_fun, .-example_fun
        .section    .rodata
    .LC1:
        .string "fn1"
        .text
        .globl  fn1
        .type   fn1, @function
    fn1:
    .LFB1:
        .cfi_startproc
        pushl   %ebp
        .cfi_def_cfa_offset 8
        .cfi_offset 5, -8
        movl    %esp, %ebp
        .cfi_def_cfa_register 5
        subl    $24, %esp
        movl    $.LC1, (%esp)
        call    puts
        leave
        .cfi_restore 5
        .cfi_def_cfa 4, 4
        ret
        .cfi_endproc
    .LFE1:
        .size   fn1, .-fn1
        .section    .rodata
    .LC2:
        .string "fn2"
        .text
        .globl  fn2
        .type   fn2, @function
    fn2:
    .LFB2:
        .cfi_startproc
        pushl   %ebp
        .cfi_def_cfa_offset 8
        .cfi_offset 5, -8
        movl    %esp, %ebp
        .cfi_def_cfa_register 5
        subl    $24, %esp
        movl    $.LC2, (%esp)
        call    puts
        leave
        .cfi_restore 5
        .cfi_def_cfa 4, 4
        ret
        .cfi_endproc
    .LFE2:
        .size   fn2, .-fn2
        .globl  main
        .type   main, @function
    main:
    .LFB3:
        .cfi_startproc
        pushl   %ebp
        .cfi_def_cfa_offset 8
        .cfi_offset 5, -8
        movl    %esp, %ebp
        .cfi_def_cfa_register 5
        andl    $-16, %esp
        subl    $32, %esp
        movl    $example_fun, 24(%esp)
        movl    $fn1, 16(%esp)
        movl    $fn2, 20(%esp)
        movl    $2, (%esp)
        movl    24(%esp), %eax
        call    *%eax
        movl    $0, (%esp)
        call    time
        movl    %eax, (%esp)
        call    srand
        call    rand
        movl    %eax, %ecx
        movl    $-2147483645, %edx
        movl    %ecx, %eax
        imull   %edx
        leal    (%edx,%ecx), %eax
        movl    %eax, %edx
        sarl    $29, %edx
        movl    %ecx, %eax
        sarl    $31, %eax
        movl    %edx, %ecx
        subl    %eax, %ecx
        movl    %ecx, %eax
        movl    %eax, 28(%esp)
        movl    28(%esp), %eax
        testl   %eax, %eax
        je  .L6
        cmpl    $1, %eax
        je  .L7
        jmp .L9
    .L6:
        movl    16(%esp), %eax
        call    *%eax
        jmp .L10
    .L7:
        movl    20(%esp), %eax
        call    *%eax
        jmp .L10
    .L9:
        movl    $1, (%esp)
        movl    24(%esp), %eax
        call    *%eax
    .L10:
        leave
        .cfi_restore 5
        .cfi_def_cfa 4, 4
        ret
        .cfi_endproc
    .LFE3:
        .size   main, .-main
        .ident  "GCC: (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1"
        .section    .note.GNU-stack,"",@progbits
    

    In all cases our calls were translated into call *%eax, which is a memory indirect call executing the function located at address pointed by %eax. Adding optimization messes the structure, but mechanics remains the register call.

    Calling a shared dynamic library (see example here) resulted in just call <function_name>. Consulting the x86 Developer Manual, call accepts either register, either memory, or pointer operand. Such a call is being treated by linker on startup and the name of the function is being substituted by the actual memory address. So, calling a shared library results (in the end) in a memory indirect call.

    Apart from such easily reproduced cases, you can encounter operations with immediate address, such as call dword ptr ds:[00923030h] (described here) or analogous jmp. I can’t provide a reasonable explanation where do they come from.

    Distinguishing between register and memory calls is pretty easy then: just look on the operand.

    If you’re interested in rootkit detection, it might be a good idea to just take some existing rootkit and look on it’s sources and generated assembly side-by-side.

    I’m not very experienced with compilers and architecture so I can mistake things a little.

    Hope it helps.

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

Sidebar

Related Questions

Can any one please make me clear what is the difference between virtual memory
Can somebody please explain me the difference between the terms high memory and high
With regards to SQL and queries, whats the difference between an in-memory table, temp
What is the difference between aligned and unaligned memory access? I work on an
Difference between a bus error and a segmentation fault? Can it happen that a
Can you describe difference between two ways of string concatenation: simple __add__ operator and
I was trying to understand the difference between early and late binding, and in
What is the difference between setting the mapred.job.map.memory.mb and mapred.child.java.opts using -Xmx to control
I want to understand better the difference between using 'new' to allocate memory for
I'm wondering about the difference between what is defined by the several standards of

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.