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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:25:33+00:00 2026-06-09T05:25:33+00:00

I don’t know how to ask this better but why does this: call ExitProcess

  • 0

I don’t know how to ask this better but why does this:

call ExitProcess

do the same as this?:

mov eax, ExitProcess
mov eax, [eax]
call eax

I would think that these would be equivalent:

call ExitProcess

mov eax, ExitProcess
call eax
  • 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-09T05:25:35+00:00Added an answer on June 9, 2026 at 5:25 am

    When importing the code from a DLL, the symbol ExitProcess isn’t actually the address of the code that exits your process (it’s the address of the address). So, in that case, you have to dereference it to get the actual code address.

    That means that you must use:

    call [ExitProcess]
    

    to call it.

    For example, there’s some code at this location containing the following:

    ;; Note how we use 'AllocConsole' as if it was a variable. 'AllocConsole', to 
    ;; NASM, means the address of the AllocConsole "variable" ; but since the 
    ;; pointer to the AllocConsole() Win32 API function is stored in that 
    ;; variable, we need to call the address from that variable. 
    ;; So it's "call the code at the address: whatever's at the address
    ;; AllocConsole" . 
    call [AllocConsole] 
    

    However, importing the DLL directly in user code is not the only way to get at the function. I’ll explain why you’re seeing both ways below.

    The "normal" means of calling a DLL function is to mark it extern then import it from the DLL:

    extern ExitProcess
    import ExitProcess kernel32.dll
    :
    call [ExitProcess]
    

    Because that sets up the symbol to be an indirect reference to the code, you need to call it indirectly.

    After some searching, it appears there is code in the wild that uses the naked form:

    call ExitProcess
    

    From what I can tell, this all seems to use the alink linker, which links with the win32.lib library file. It’s possible that this library provides the stub for calling the actual DLL code, something like:

    import ExitProcessActual kernel32.dll ExitProcess
    global ExitProcess
    
    ExitProcess:
        jmp [ExitProcessActual]
    

    In nasm, this would import the address of ExitProcess from the DLL and call it ExitProcessActual, keeping in mind that this address is an indirect reference to the code, not the address of the code itself.

    It would then export the ExitProcess entry point (the one in this LIB file, not the one in the DLL) so that others could use it.

    Then someone could simply write:

    extern ExitProcess
    :
    call ExitProcess
    

    to exit the process – the library would jump to the actual DLL code.


    In fact, with a little more research, this is exactly what’s happening. From the alink.txt file which comes with the alink download:

    A sample import library for Win32 is included as win32.lib. All named exports in Kernel32, User32, GDI32, Shell32, ADVAPI32, version, winmm, lz32, commdlg and commctl are included.

    Use:

    alink -oPE file[.obj] win32.lib

    to include it or specify

    INCLUDELIB "win32"

    in your source file.

    This consists of a series of entries for import redirection – call MessageBoxA, and it jumps to [__imp_MessageBoxA], which is in the import table.

    Thus calls to imports will run faster if call [__imp_importName] is used instead of call importName.

    See test.asm, my sample program, which calls up a message box both ways:

    includelib "win32.lib"
    extrn MessageBoxA:near
    extrn __imp_MessageBoxA:dword
    
    codeseg
    
    start:
    push 0 ; OK button
    push offset title1
    push offset string1
    push 0
    call MessageBoxA
    
    push 0 ; OK button
    push offset title1
    push offset string2
    push 0
    call large [large __imp_MessageBoxA]
    

    (__imp_MessageBoxA is the symbol imported from the DLL, equivalent to my ExitProcessActual above).

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

Sidebar

Related Questions

(Don't know if this is strictly on-topic, but I don't see any better Stack
Don't know if this is the right place to ask this, but I will
don't know better title for this, but here's my code. I have class user
I don't know why, but this code worked for me a month ago... maybe
Don't know how to explain it better but i'm trying to get a response
I don't know if this question is trivial or not. But after a couple
Don't know where else to ask, but from one day to the other my
Don't know why this is happening, but after submitting a form via JS (using
Don't know if this is an eclipse specific problem but whenever I declare a
Don't know if I'm over-thinking this or not.. but I'm trying to be able

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.