I try to code the pipe example from ICZelion in NASM and got a error in process creation
if any one can say some thing...

here it is:

;- MUSIC WHILE CODING Mundo Civilizado ARTO LINDSAY -
;---------------------------------------------------------
; NaGoA RAD IDE http://visual-assembler.pt.vu
;---------------------------------------------------------


extern LoadIconA
extern LoadCursorA
extern RegisterClassExA
extern GetMessageA
extern TranslateMessage
extern DispatchMessageA
extern CreateWindowExA
extern MoveWindow
extern CreatePipe
extern MessageBoxA
extern CreateProcessA
extern SendMessageA
extern CloseHandle
extern PostQuitMessage
extern DefWindowProcA
extern GetStartupInfoA
extern ReadFile
extern RtlZeroMemory
extern ShowWindow
extern GetModuleHandleA
extern ExitProcess
extern SetTextColor
extern SetBkColor
extern GetStockObject

%include "\lab\vasm\inc\win32n.inc"
%include "\lab\vasm\inc\nagoa.inc"



Instance dd 0
WndClassEx resb WNDCLASSEX_size
Atom dd 0
WindowName db "Nasm PIPE example", 0
WindowHandle dd 0
Msg resb MSG_size
sat resb SECURITY_ATTRIBUTES_size
IDR_MAINMENU equ 101
IDM_ASSEMBLE equ 40001
ClassName db "PIPEnasm",0
AppName db "One-way Pipe Example thanks Iczelion! :)",0
EditClass db "EDIT",0
CreatePipeError db "Error during pipe creation",0
CreateProcessError db "Error during process creation",0
CommandLine db "c:\lab\vasm\gorc pipe.rc",0

hwndEdit dd 0
wc resb WNDCLASSEX_size
hwnd dd 0
rect resb RECT_size
hRead dd 0
hWrite dd 0
startupinfo resb STARTUPINFO_size
pinfo resb PROCESS_INFORMATION_size
buffer resd 1024
bytesRead dd 0




;--------------- THE CODE ------------------------------------------------


..start:
call GetModuleHandleA, 0
mov dword , eax



call WinMain, , NULL, NULL, SW_SHOWDEFAULT

call ExitProcess, eax



WinMain:



%define hInstance ebp+8
%define hPrevInstace ebp+12
%define lpCmdLine ebp+16
%define nCmdShow ebp+20


enter 0, 0 ;clear the stack reset

; fill values in members of wc that we give the name of WndClassEx.
;it?s how it will be our window load icon?s cursor type of window etc..
;============================================

mov dword , WNDCLASSEX_size
mov dword , CS_HREDRAW + CS_VREDRAW
mov dword , WindowProc
mov dword , 0
mov dword , 0
mov eax, dword
mov dword , eax

call LoadIconA, NULL, IDI_APPLICATION
mov dword , eax
mov dword , eax

call LoadCursorA, NULL, IDC_ARROW
mov dword , eax

mov dword , COLOR_APPWORKSPACE
mov dword ,IDR_MAINMENU
mov dword , ClassName
call LoadIconA,NULL,IDI_APPLICATION
mov dword ,eax
mov dword ,0
call LoadCursorA,NULL,IDC_ARROW
mov dword ,eax
call RegisterClassExA, WndClassEx
test eax, eax
jne .DoAndShow
jmp .erro



.DoAndShow:
mov dword , eax
call CreateWindowExA,WS_EX_CLIENTEDGE,,AppName,WS_OVERLAPPEDWINDOW+WS_VISIBLE,CW_USEDEFAULT,CW_USEDEFAULT,400,200,NULL,NULL,,NULL



test eax, eax
je near .erro
mov dword , eax
call ShowWindow, ,





; Loop Messages in order to get all of them..
;============================
.Messageloop
call GetMessageA, Msg, NULL, 0, 0

test eax, eax
je .Fim

cmp eax, -1
je .erro

call TranslateMessage, Msg
call DispatchMessageA, Msg

jmp .Messageloop

.Fim:
mov eax, dword

leave
ret 16
.erro
xor eax, eax

leave
ret 16


WindowProc:
;===============================================
;here the messages that are inputed by the user are processed , did he clicked button x ....
;*****************************************************
;* WindowProc(hwnd, uMsg, wParam, lParam); *
;*****************************************************
%define hwnd ebp+8 ;it?s the handle of our application an aplication as a instance and a handle
%define uMsg ebp+12
%define wParam ebp+16
%define lParam ebp+20


enter 0, 0

mov eax, dword

cmp eax, WM_DESTROY
je near .Destroy
cmp eax, WM_CREATE
je near .Create
cmp eax, WM_COMMAND
je near .Command
cmp eax,WM_SIZE
je .Size
cmp eax,WM_CTLCOLOREDIT
je .ColorEdit




.Defaut:
call DefWindowProcA, , , ,

leave
ret 16

.Size
mov edx,
mov ecx,edx
shr ecx,16
and edx,0FFFFh
call MoveWindow,,0,0,edx,ecx,FALSE

leave
ret 16

.ColorEdit
call SetTextColor,,Yellow
call SetBkColor,,Black
call GetStockObject,BLACK_BRUSH

leave
ret 16

;==================================
;Create here your front hend of your aplication!! Make a button a combobox etc..
;==================================
.Create

call CreateWindowExA,NULL,EditClass,NULL,WS_CHILD+WS_VISIBLE+ES_MULTILINE+ES_AUTOHSCROLL+ES_AUTOVSCROLL ,0,0,0,0,,NULL,,NULL
mov ,eax




xor eax, eax
leave
ret 16

;=============================
;-------------------------wmcommand start
;=============================
.Command:

cmp dword ,0
jne near .goOUT
mov eax, dword
cmp ax,IDM_ASSEMBLE
jne near .goOUT
mov dword ,SECURITY_ATTRIBUTES_size
mov dword ,NULL
mov dword ,TRUE

call CreatePipe,hRead,hWrite,sat,NULL
test eax,eax
jnz .gostartupinfo
call MessageBoxA,,CreatePipeError, AppName,MB_ICONERROR + MB_OK
jmp .goOUT
.gostartupinfo
mov dword ,STARTUPINFO_size
call GetStartupInfoA,startupinfo
mov eax,hWrite
mov dword ,eax
mov dword ,eax
mov dword ,STARTF_USESHOWWINDOW+STARTF_USESTDHANDLES
mov dword ,SW_HIDE

;------------------------------------------
; Create process
;------------------------------------------
call CreateProcessA,NULL,CommandLine,NULL,NULL,TRUE,NULL,NULL,NULL, startupinfo,pinfo
test ax,0
jnz .go2
call MessageBoxA,,CreateProcessError,AppName,MB_ICONERROR+MB_OK
jmp .goCloseHandle
.go2
call CloseHandle,hWrite
.goo1
call RtlZeroMemory,buffer,1024
call ReadFile,hRead,buffer,1023,bytesRead,NULL
test ax,0
jnz .go3
jmp .goCloseHandle
.go3
call SendMessageA,,EM_SETSEL,-1,0
call SendMessageA,,EM_REPLACESEL,FALSE,buffer
jmp .goo1
.goCloseHandle
call CloseHandle,hRead
jmp .goOUT

.goOUT
xor eax, eax
leave
ret 16


;===========================
;--------------------- wmcommand end
;===========================

.Destroy

call PostQuitMessage, 0

xor eax, eax
leave
ret 16
Posted on 2001-08-21 22:43:31 by Nguga