News:

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

ReadFile on FIlepipe returning Junk

Started by AgentSmithers, April 29, 2011, 05:28:54 AM

Previous topic - Next topic

AgentSmithers

Anyone know why this app is getting junk, Is it the Client?

.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\Ws2_32.inc
include \masm32\include\advapi32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\Ws2_32.lib
includelib \masm32\lib\advapi32.lib

.data
PipeName db "\\.\pipe\MyPipe", 0
Buffer DB 128 dup (0)

.data?

hPipe dd ?
OpenMode dd ?
PipeMode dd ?
BytesReturned dd ?

.code
start:
mov OpenMode, PIPE_ACCESS_DUPLEX
or OpenMode, FILE_FLAG_WRITE_THROUGH
mov PipeMode, PIPE_WAIT
or PipeMode, PIPE_TYPE_MESSAGE
or PipeMode, PIPE_READMODE_MESSAGE
invoke CreateNamedPipe, ADDR PipeName, OpenMode, PipeMode, 10, 10000, 2000, 10000, 0
mov hPipe, eax
invoke ConnectNamedPipe, hPipe, 0
invoke ReadFile, [hPipe], ADDR Buffer, 128, ADDR BytesReturned, 0
Invoke MessageBoxA, 0, ADDR Buffer, ADDR PipeName, 0

exit:
invoke ExitProcess,0
end start


I wanted to see if any of you can confirm, it appears when I send it a string from CallNamedPipe, a VB.net application it gets back junk.
Can anyone throw a quick test together, I'm kinda stumped.

Thanks!

-Agent

AgentSmithers

I figured it out, There was a issue with the sending client =(

clive

Quote from: AgentSmithers
Can anyone throw a quick test together, I'm kinda stumped.

Dude, you have no error handling, and you don't inspect the bytes returned parameter, or handle any null termination issues. There are various degrees of working and failing, expecting that a function will always succeed is pretty foolhardy.
It could be a random act of randomness. Those happen a lot as well.

AgentSmithers

Quote from: clive on April 29, 2011, 02:55:33 PM
Quote from: AgentSmithers
Can anyone throw a quick test together, I'm kinda stumped.

Dude, you have no error handling, and you don't inspect the bytes returned parameter, or handle any null termination issues. There are various degrees of working and failing, expecting that a function will always succeed is pretty foolhardy.

Thats how I roll :)

I use immunity for debugging, it was not required at this stage in development.