And you get wrong result = stack disbalance. To push byte is imposible at all!
I wrote this to delete this problem(word and byte). I was using the edx
macro cinvoke function*,[arg]
{
;this alows(very simple example):
; cinvoke sprintf,edi,szTime,word [mytime.wYear],byte [mytime.wMonth],\
; dword [mytime.wDayOfWeek]
;
; it's will return correct results '
common
local parsed_var,edx_zero,param_cntr
edx_zero = 0
param_cntr = 0
reverse
parsed_var = 0
if arg eq
else
if arg eqtype [ebp+0]
parsed_var = 1
push dword arg
else
match type some,arg
\{
parsed_var = 1
if type in <addr,Addr,ADDR,>
replace addr, ,Addr, ,ADDR
lea edx,[arg]
edx_zero =0
restore addr,Addr,ADDR
push edx
end if
if type in <b,B,byte,BYTE,Byte>
replace b, ,byte, ,BYTE, ,Byte,
if edx_zero <= 2
xor edx,edx
end if
mov dl,arg
edx_zero = 3
restore b,byte,BYTE,Byte
push edx
end if
if type in <word,Word,WORD,w,W>
replace w,Word,W,Word
if edx_zero = 0
xor edx,edx
end if
mov dx,arg
dx_zero = 2
push edx
restore w,W
end if
if type in <dword,Dword,DWORD,dw,d,D,DW,Dw>
replace d,dword,dw,dword,D,dword,DW,dword,Dw,dword
push arg
restore d,D,dw,DW,Dw
end if
if type eq invoke
arg
push eax
edx_zero =0
end if
\}
end if
if parsed_var = 0
push arg
end if
end if
common
reverse
if ~arg eq
param_cntr = param_cntr + 1
end if
common
call [function]
if param_cntr > 0
if param_cntr = 2
pop edx
pop edx
end if
if param_cntr = 1
pop edx
end if
if param_cntr > 2
add esp,param_cntr*4
end if
end if
}
;all code had optimized by size and have some trick : ).
;play with this macros, find bug or useful properties