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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:35:51+00:00 2026-06-15T15:35:51+00:00

I assumed I had push’ed something without popping it, or vice versa, but I

  • 0

I assumed I had push’ed something without popping it, or vice versa, but I can’t find anything wrong! I write to the console with a call to a dll that links properly, and I inexplicably am in no mans land… (address 0x0000000000000000)

I’ve put some sleeps in, and I’m sure that the api call WriteConsoleA is returning. It’s on my last ret under the print function.

Any ideas?

.exe:

extern FreeConsole
extern Sleep
extern ExitProcess

extern print
extern newconsole
extern strlen

section .data BITS 64
        title:  db 'Consolas!',0

        message: db 'Hello, world',0,0

section .text bits 64
global Start
Start:
        mov rcx, title
        call newconsole
        mov rcx, 1000
        call Sleep

        mov rcx, message
        call print

        mov rcx, 10000
        call Sleep
        call FreeConsole
        xor rcx, rcx
        call ExitProcess

.dll:

extern AllocConsole
extern SetConsoleTitleA
extern GetStdHandle
extern WriteConsoleA
extern Sleep

export newconsole
export strlen
export print

section .data BITS 64
console.writehandle:     dq 0
console.readhandle:              dq 0
console.write.result:    dq 0

section .text BITS 64
global strlen
strlen:
        push rax
        push rdx
        push rdi

        mov rdi, rcx
        xor rax, rax
        mov rcx, dword -1
        cld

        repnz scasb
        neg rcx
        sub rcx, 2

        pop rdi
        pop rdx
        pop rax
        ret

global print
print:
        mov rbp, rsp
        push rcx
        call strlen

        mov r8, rcx
        pop rdx
        mov rcx, [console.writehandle]
        mov r9, console.write.result
        push qword 0
        call WriteConsoleA
        ret

global newconsole
newconsole:
        push rax
        push rcx
        call AllocConsole
        pop rcx
        call SetConsoleTitleA
        mov rcx, -11
        call GetStdHandle
        mov [console.writehandle], rax
        pop rax
        ret
  • 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-15T15:35:52+00:00Added an answer on June 15, 2026 at 3:35 pm

    I assume you’re talking about this function:

    global print
    print:
            mov rbp, rsp
            push rcx
            call strlen
    
            mov r8, rcx
            pop rdx
            mov rcx, [console.writehandle]
            mov r9, console.write.result
            push qword 0
            call WriteConsoleA
            ret
    

    The x64 ABI requires that stack space is reserved even for parameters passed in registers. WriteConsoleA is free to use those stack locations for whatever it wants – so you need to make sure that you’ve adjusted the stack appropriately. As it stands, you’re pushing only the last reserved pointer parameter. I think something like the following will do the trick for you:

            push qword 0
            sub rsp, 4 * 8  // reserve stack for register parameters
            call WriteConsoleA
            mov rsp, rbp    // restore rsp
            ret
    

    See http://msdn.microsoft.com/en-us/library/ms235286.aspx (emphasis added):

    The x64 Application Binary Interface (ABI) is a 4 register fast-call calling convention, with stack-backing for those registers.

    …

    The caller is responsible for allocating space for parameters to the callee, and must always allocate sufficient space for the 4 register parameters, even if the callee doesn’t have that many parameters.

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

Sidebar

Related Questions

I had assumed the maximum was 9 but after some experimentation I know it
Today I discovered that something I had assumed about VB.NET for many years was
Apparently, my understanding of .resx files was flawed - I had assumed (without testing)
I had assumed it would be as simple as $ENV{TZ} , but the TZ
I have had to make changes to a trigger and assumed that running an
I had assume I could just do this, but I don't have a way
I assumed it was strictly by the meta 'description' tag. But I noticed that
What does time(NULL) return? Given documentation I had assumed it returns the number of
I have stemming enabled in my Solr instance, I had assumed that in order
I had assumed that the canonical form for operator+, assuming the existence of an

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.