News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

WriteConsole - GetLastError = 8

Started by DKOI, September 20, 2011, 03:59:42 PM

Previous topic - Next topic

DKOI

.686
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\macros\macros.asm
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\shlwapi.inc

includelib \masm32\lib\masm32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\shlwapi.lib

.data
HEAP DD ?
TERM DD ?
message BYTE "215",10,13
by DWORD ?

.stack
DD 256 DUP(?)

.code
start:
fn GetProcessHeap
mov HEAP, EAX
fn HeapAlloc, HEAP, 0, 1
mov EBX, EAX
mov AL, 5
mov [EBX], AL
fn GetStdHandle, STD_OUTPUT_HANDLE
mov TERM, EAX
fn WriteConsole, TERM, ADDR message, [EBX], ADDR by, 0
fn HeapFree, HEAP, 0, EBX
fn Sleep, 1000
fn ExitProcess, 0
end start

I run it and text "215" doesn't appear, just command prompt are printed again. GetLastError after WriteConsole return 8 as error code, that's defined as ERROR_NOT_ENOUGH_MEMORY, but i don't actually know, what it mean. Can anybody give me answer, where error is? Sorry for bad english.

qWord

You are passing a DWORD, pointed by ebx, to WriteConsole, but only one byte is allocated and filled.
FPU in a trice: SmplMath
It's that simple!

DKOI

Quote from: qWord on September 20, 2011, 04:42:54 PM
You are passing a DWORD, pointed by ebx, to WriteConsole, but only one byte is allocated and filled.
Oh, thanx, it works :)