But it's not support cdecl dll api

Quote Originally Posted by wqweto View Post
nops do not take any cpu cycles on execution nowadays but i use these to align following offsets in the thunk so to make "codegen" of the variable num_of_args easier like this

Code:
option explicit

private declare sub copymemory lib "kernel32" alias "rtlmovememory" (destination as any, source as any, byval length as long)
private declare function virtualprotect lib "kernel32" (byval lpaddress as long, byval dwsize as long, byval flnewprotect as long, lpfloldprotect as long) as long

public function call_ultow(byval pfn as long, byval value as long, byval str as long, byval radix as long, optional byval spacer as long) as long
    pvpatchtrampoline addressof module1.call_ultow, 3
    call_ultow = call_ultow(pfn, value, str, radix)
end function

private sub form_click()
    dim hlib            as long
    dim pfn             as long
    dim sbuffer         as string
    
    hlib = loadlibrary("msvcrt")
    pfn = getprocaddress(hlib, "_ultow")
    
    sbuffer = string(50, 0)
    call_ultow pfn, &h80212123, strptr(sbuffer), 10
    msgbox "[" & replace(sbuffer, vbnullchar, vbnullstring) & "]"
end sub
the extra spacer parameter was the invention in this thread. Kudos!

Cheers,
</wqw>