Page 1 of 1

feed callfunctionfast with dynamic params

Posted: Tue Mar 11, 2008 11:04 pm
by Lukaso
hi,
i work on some rpc procedures for pb to make a generalized protocol for some of my projects.
the problem that currently occured is that i have no idea how to feed callprocedure fast dynamicly with vars.

I look for something like this (pseudocode):

Code: Select all

*funcaddr = @bla()
appendParamString(*funcaddr, "string")
appendParamLong(*funcaddr, 234234)
appendParamByte(*funcaddr, 123)
callProcedure(*funcaddr)
I dont have alot of knowleadge about asm, but maybe it is possible to push the vars dynamicly on a stack.

maybe someone can help me :)

thanks, lukas

Posted: Tue Mar 11, 2008 11:41 pm
by Deeem2031
Something like this?

Code: Select all

Procedure bla(s.s,l.l,b.b,f.f,q.q,d.d) 
  Debug s 
  Debug l 
  Debug b 
  Debug f.f
  Debug Hex(q)
  Debug d
  
  ProcedureReturn 2031
EndProcedure 

Procedure callProcedure(adr,ll.l()) 
  Protected tmp 
  !MOV Edx, dword[p.v_adr] 
  !MOV Eax, dword[p.v_adr+4] 
  !MOV Eax, dword[Eax] 
  !MOV Eax, dword[Eax+4] 
  
  !asm_callProcedure_loop: 
  !OR Eax, Eax 
  !JZ asm_callProcedure_loop_end
  !PUSH dword[Eax+8] 
  !MOV Eax, dword[Eax+4] 
  !JMP asm_callProcedure_loop
  !asm_callProcedure_loop_end:
  
  !CALL Edx 
  
  ProcedureReturn
EndProcedure 

Procedure callProcedure_AddString(ll.l(),*s)
  AddElement(ll()) 
  ll() = *s
EndProcedure

Procedure callProcedure_AddLong(ll.l(),l.l)
  AddElement(ll()) 
  ll() = l
EndProcedure

Procedure callProcedure_AddFloat(ll.l(),f.f)
  AddElement(ll()) 
  ll() = PeekL(@f)
EndProcedure

Procedure callProcedure_AddQuad(ll.l(),q.q)
  AddElement(ll()) 
  ll() = PeekL(@q)
  AddElement(ll()) 
  ll() = PeekL(@q+4)
EndProcedure

Procedure callProcedure_AddDouble(ll.l(),d.d)
  AddElement(ll()) 
  ll() = PeekL(@d)
  AddElement(ll()) 
  ll() = PeekL(@d+4)
EndProcedure


*funcaddr = @bla() 
NewList ll() 
callProcedure_AddString(ll(),@"string")
callProcedure_AddLong(ll(),23456)
callProcedure_AddLong(ll(),123)
callProcedure_AddFloat(ll(),123.456)
callProcedure_AddQuad(ll(),$12345678ABCDEF09)
callProcedure_AddDouble(ll(),123.45678)

Debug callProcedure(*funcaddr, ll())

Posted: Thu Mar 13, 2008 9:42 pm
by Lukaso
Wee, my hero :)
Thank you :D

Some bonus questions (not, assantual for me): what about quad/double/float ... and will it work under linux too?