flat assembler
Message board for the users of flat assembler.

Index > Windows > [solved] Odd issue with 64-bit MSVCRT printf invocation

Author
Thread Post new topic Reply to topic
Trinitek



Joined: 06 Nov 2011
Posts: 257
Trinitek 27 Mar 2017, 06:27
I've got a heisenbug on my hands. The following works on my Win7 machine and my debugger without problems, but fails on Win10.
Code:
format PE64 console
entry start

    include "win64a.inc"

section '.text' code readable executable
    
    start:
        invoke printf, msg_helloWorld
        invoke ExitProcess, 0
        
    msg_test db "Test", 0x0D, 0x0A, 0
    
section '.data' data readable

    msg_helloWorld db "Hello world!", 0x0D, 0x0A, 0
    
section '.idata' import data readable writeable

    library kernel32,'KERNEL32.DLL',\
            msvcrt, 'MSVCRT.DLL'
    
    include 'api/kernel32.inc'
    
    import  msvcrt,\
            printf, 'printf'    
Any ideas? inb4 Windows 10? More like WinBLOWS 10 am I rite???
Post 27 Mar 2017, 06:27
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
revolution 27 Mar 2017, 06:38
What do you mean by "fails on Win10"? Crashes? Prints something else? Prints nothing? Infinite loop? Can't start? Can't debug?
Post 27 Mar 2017, 06:38
View user's profile Send private message Visit poster's website Reply with quote
Trinitek



Joined: 06 Nov 2011
Posts: 257
Trinitek 27 Mar 2017, 06:44
revolution wrote:
What do you mean by "fails on Win10"? Crashes? Prints something else? Prints nothing? Infinite loop? Can't start? Can't debug?
It crashes and burns. "ConsoleTest.exe has stopped working."
Post 27 Mar 2017, 06:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
revolution 27 Mar 2017, 06:50
Probably because the stack is misaligned.

Try inserting this after the start label:
Code:
and rsp,-16    
Post 27 Mar 2017, 06:50
View user's profile Send private message Visit poster's website Reply with quote
Trinitek



Joined: 06 Nov 2011
Posts: 257
Trinitek 27 Mar 2017, 06:55
Stupid stack alignments. Thanks a bunch.
Post 27 Mar 2017, 06:55
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.