flat assembler
Message board for the users of flat assembler.
Index
> Windows > how this would work? |
Author |
|
LocoDelAssembly 29 Nov 2009, 02:45
Before anything, fix your string, you have to end it with a NULL and remove the CR characters because them are redundant with the C API, using LF is enough:
Code: hello_msg db 'Programa victima de una inyeccion',10,\ 'El objetivo es conseguir que muestre 1',10,\ ' ',10,\ 0 ; End of NULL terminated string Now the problem just seems to be that you forgot to pass a format string to the second printf and that you were passing a pointer to a rather than its content: Code: cinvoke printf, fmt, [a] cinvoke getchar invoke ExitProcess, 0 fmt db '%d', 10, 0 BTW, if the program objective really is to show 1 then replace "mov eax, 0" with "mov eax, 1" or even just "mov [a], 1" and discard all the other instructions. |
|||
29 Nov 2009, 02:45 |
|
asmMe 18 Jul 2011, 16:06
Loco, off topic but...
Quote:
Is the CR placed by C automatically or is it just not used? My reason for asking.. Try opening a '*.txt' file that has LFs but no corresponding CR in Notepad.exe. It doesn't recognize LFs as a newline without the CR |
|||
18 Jul 2011, 16:06 |
|
LocoDelAssembly 18 Jul 2011, 17:04
Code: format PE console 4.0 include 'win32a.inc' entry start section '.code' readable executable fmt db 10, 0 start: cinvoke printf, fmt invoke ExitProcess,0 section '.idata' data import readable writeable library kernel32,'kernel32.dll',msvcrt,'msvcrt.dll' import kernel32,ExitProcess,'ExitProcess' import msvcrt,printf,'printf' Code: CPU Dump Address Hex dump ASCII 0007FAF8 0D 0A .. Code: CPU Dump Address Hex dump ASCII 0007FAF8 0D 0D 0A ... Haven't checked what happens with fprintf, could you contribute that test? |
|||
18 Jul 2011, 17:04 |
|
asmMe 18 Jul 2011, 21:09
Thanks for the clarification Loco.
I don't use any of the cinvoke functions, I have similar ones written from years ago that I still use. |
|||
18 Jul 2011, 21:09 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.