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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:55:11+00:00 2026-06-02T00:55:11+00:00

This is C++ using x86 inline assembly [Intel syntax] Function: DWORD *Call ( size_t

  • 0

This is C++ using x86 inline assembly [Intel syntax]

Function:

     DWORD *Call ( size_t lArgs, ... ){

    DWORD *_ret = new DWORD[lArgs];

    __asm {
        xor edx, edx
        xor esi, esi
        xor edi, edi
        inc edx
start:
        cmp edx, lArgs
        je end
        push eax
        push edx
        push esi
        mov esi, 0x04
        imul esi, edx
        mov ecx, esi
        add ecx, _ret
        push ecx
        call dword ptr[ebp+esi] //Doesn't return to the next instruction, returns to the caller of the parent function.
        pop ecx
        mov [ecx], eax
        pop eax
        pop edx
        pop esi
        inc edx
        jmp start
end:
        mov eax, _ret
        ret
    }
}

The purpose of this function is to call multiple functions/addresses without calling them individually.

Why I’m having you debug it?
I have to start school for the day, and I need to have it done by evening.

Thanks alot, iDomo

  • 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-02T00:55:13+00:00Added an answer on June 2, 2026 at 12:55 am

    Thank you for a complete compile-able example, it makes solving problems much easier.

    According to your Call function signature, when the stack frame is set up, the lArgs is at ebp+8 , and the pointers start at ebp+C. And you have a few other issues. Here’s a corrected version with some push/pop optimizations and cleanup, tested on MSVC 2010 (16.00.40219.01) :

    DWORD *Call ( size_t lArgs, ... ) {
    
        DWORD *_ret = new DWORD[lArgs];
    
        __asm {
            xor edx, edx
            xor esi, esi
            xor edi, edi
            inc edx
            push esi
    start:
            cmp edx, lArgs
            ; since you started counting at 1 instead of 0
            ; you need to stop *after* reaching lArgs
            ja end
            push edx
            ; you're trying to call [ebp+0xC+edx*4-4]
            ; a simpler way of expressing that - 4*edx + 8
            ; (4*edx is the same as edx << 2)
            mov esi, edx
            shl esi, 2
            add esi, 0x8
            call dword ptr[ebp+esi]
            ; and here you want to write the return value
            ; (which, btw, your printfs don't produce, so you'll get garbage)
            ; into _ret[edx*4-4] , which equals ret[esi - 0xC]
            add esi, _ret
            sub esi, 0xC
            mov [esi], eax
            pop edx
            inc edx
            jmp start
    end:
            pop esi
            mov eax, _ret
            ; ret ; let the compiler clean up, because it created a stack frame and allocated space for the _ret pointer
        }
    }
    

    And don’t forget to delete[] the memory returned from this function after you’re done.

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

Sidebar

Related Questions

I am trying to familiarise myself with x86 assembly using GCC's inline assembler. I'm
When I say this using (Entities db = new Entities()) { return db.TableName.AsQueryable().ToList(); }
I see this: using (StreamWriter sw = new StreamWriter(file.txt)) { // d0 w0rk s0n
My Code goes like this: using (StreamReader streamReader1 = new StreamReader(response.GetResponseStream())) { string resultString
I am building a COM object in x86 assembly using NASM. I understand COM
I am using this code right now: ProcessStartInfo startInfo = new ProcessStartInfo(); Process process
How does one implement alloca() using inline x86 assembler in languages like D, C,
Using x86 platform , I want to start my application named myapp through this
I am writing an assembly function to be called from C that will call
I am optimizing some code for an Intel x86 Nehalem micro-architecture using SSE intrinsics.

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.