More ASM

Posts 1–6 of 6 · Page 1 of 1
More ASM
I am most likely making a very stupid mistake, but if you could point it out, I would greatly appreciate it.


I am moving the HANDLE to output and HANDLE to input into two different variables. When i use those variables as the handle parameter to ReadConsole and WriteConsole, it doesn't work. Here is my code:


Code:
.386
.model flat, stdcall
option casemap :none


include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

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




.data 
hello db "Hello", 0
szbuffer db 64 dup (0), 0ah

.data?
writehandle dd ?
readhandle  dd ?

.code

start:


invoke GetStdHandle, STD_INPUT_HANDLE
mov writehandle, eax
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov readhandle, eax






invoke ReadConsole, readhandle, offset szbuffer, sizeof szbuffer, ebx, NULL

invoke WriteConsole, writehandle, offset szbuffer, sizeof szbuffer, ebx, NULL

invoke MessageBox, NULL, offset szbuffer, offset hello, MB_OK



invoke ExitProcess, 0 
 


end start
Thanks in advance.
i know you are reading this mmbob, ANSWER. Lol
really? i am positive there are more than 6 people more proficient than i am in asm.
I don't know shit about asm. So I can't help.
Quote Originally Posted by 258456 View Post
I am most likely making a very stupid mistake, but if you could point it out, I would greatly appreciate it.


I am moving the HANDLE to output and HANDLE to input into two different variables. When i use those variables as the handle parameter to ReadConsole and WriteConsole, it doesn't work. Here is my code:


Code:
.386
.model flat, stdcall
option casemap :none


include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

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




.data 
hello db "Hello", 0
szbuffer db 64 dup (0), 0ah

.data?
writehandle dd ?
readhandle  dd ?

.code

start:


invoke GetStdHandle, STD_INPUT_HANDLE
mov writehandle, eax
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov readhandle, eax






invoke ReadConsole, readhandle, offset szbuffer, sizeof szbuffer, ebx, NULL

invoke WriteConsole, writehandle, offset szbuffer, sizeof szbuffer, ebx, NULL

invoke MessageBox, NULL, offset szbuffer, offset hello, MB_OK



invoke ExitProcess, 0 
 


end start
Thanks in advance.
There's nothing wrong with the handles. But you're supplying a null pointer to the function at: LPDWORD lpNumberOfCharsWritten. Instead of pushing ebx try pushing the address of a dword or memory location.
You can also use the stack to do this:


Code:
push 0                              ; empty a spot on the stack
invoke WriteConsole, writehandle, offset szbuffer, sizeof szbuffer, esp, NULL
pop ebx                            ; fix the stack & receive the bytes received in ebx
Schim, I don't understand. It works perfectly if i just use ebx.
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us