Discussion:
Borlands tasm32 v5, calling by pointer and assemble-time checking the provided arguments
(too old to reply)
R.Wieser
2020-04-09 12:53:04 UTC
Permalink
Hello all,

I'm Using Borlands Tasm32 v5, and am calling a procedure by pointer (a
callback). The problem is that it doesn't (can't) do any assemble-time
checking of the provided arguments, while this does happen when calling the
function by value.

example:

;-- Definition of the procedure
TheFunction PROCDESC @@lArgOne:DWORD,@@lArgTwo:DWORD

;-- A by-pointer call
mov [@@pFunction],offset [TheFunction]
...
call [@@pFunction], eax, 42, -1 ;<- Too many arguments, but not detected.

;-- A by-value call
call TheFunction, eax, 42, -1 ;<- detected

My question, (how) can I tell the by-pointer call which procedure it is
targetting, so that its (number and type of) arguments can be checked ?

Regards,
Rudy Wieser
JJ
2020-04-10 05:57:51 UTC
Permalink
Post by R.Wieser
Hello all,
I'm Using Borlands Tasm32 v5, and am calling a procedure by pointer (a
callback). The problem is that it doesn't (can't) do any assemble-time
checking of the provided arguments, while this does happen when calling the
function by value.
;-- Definition of the procedure
;-- A by-pointer call
....
;-- A by-value call
call TheFunction, eax, 42, -1 ;<- detected
My question, (how) can I tell the by-pointer call which procedure it is
targetting, so that its (number and type of) arguments can be checked ?
Regards,
Rudy Wieser
PROCDESC should work. PROCTYPE can also be used as alternative.
R.Wieser
2020-04-10 07:47:36 UTC
Permalink
JJ,
Post by JJ
PROCDESC should work. PROCTYPE can also be used as alternative.
I'm not sure what you are saying there or where it should work ...

The problem is the "call [@@pFunction]" line (not detecting an argument
mismatch). I should put either of the above in there ? I tried that
before posting, but the assembler just threw an error.

Regards,
Rudy Wieser
JJ
2020-04-11 03:01:33 UTC
Permalink
Post by R.Wieser
I'm not sure what you are saying there or where it should work ...
mismatch). I should put either of the above in there ? I tried that
before posting, but the assembler just threw an error.
Here's a snippet from TASM5 User's Guide, Chapter 13, "Calling procedures
that have been prototyped".

[quote]
You can also use procedure types (declared with PROCTYPE) to supply a
distance and language, and force type-checking to occur. For example,

footype proctype pascal near :word, :dword, :word
.
.
call footype ptr[bx],ax,ds bx,cs ;no error!
[/quote]
R.Wieser
2020-04-11 07:19:26 UTC
Permalink
JJ,
Post by JJ
Here's a snippet from TASM5 User's Guide, Chapter 13, "Calling
procedures that have been prototyped".
Alas, all I get with your exact example (using v5.0 and v5.4) is an error:

"Can't generate instance of type: footype"

I can't even think how it can throw that error at *assemble* time - it
should not be generating instances of anything.

I also tried it with an existing procedure, but got the same result.

Regards,
Rudy Wieser

Loading...