Discussion:
Borlands Tasm32 v5 and external values (in a DLL)
(too old to reply)
R.Wieser
2024-04-17 15:40:12 UTC
Permalink
Hello all,

I've been using Borlands Tasm32 v5 for a while now, but have a bit of a
problem with declaring strings and values inside a dll.

For instance, CRTDLL.DLL exposes "_iob", which is/should be (a pointer to)
an array of stdio control structures.

And I have no idea how to define it. :-|

Worse: when I checked _IOB points to a "JMP [...]" (indirect jump) byte
sequence (and not a pointer to the actual data).

The question is, does anyone (stil) know how to declare such an external
value / string ?

Regards,
Rudy Wieser
Rosario19
2024-04-24 14:55:02 UTC
Permalink
Post by R.Wieser
Hello all,
I've been using Borlands Tasm32 v5 for a while now, but have a bit of a
problem with declaring strings and values inside a dll.
For instance, CRTDLL.DLL exposes "_iob", which is/should be (a pointer to)
an array of stdio control structures.
And I have no idea how to define it. :-|
Worse: when I checked _IOB points to a "JMP [...]" (indirect jump) byte
sequence (and not a pointer to the actual data).
The question is, does anyone (stil) know how to declare such an external
value / string ?
Regards,
Rudy Wieser
this seems to speak of write one dll in tasm
https://tolik-punkoff.com/2022/05/09/writing-win32-programs-in-assembly-language-using-tasm/
Rosario19
2024-04-24 15:10:31 UTC
Permalink
Post by Rosario19
Post by R.Wieser
Hello all,
I've been using Borlands Tasm32 v5 for a while now, but have a bit of a
problem with declaring strings and values inside a dll.
For instance, CRTDLL.DLL exposes "_iob", which is/should be (a pointer to)
an array of stdio control structures.
And I have no idea how to define it. :-|
Worse: when I checked _IOB points to a "JMP [...]" (indirect jump) byte
sequence (and not a pointer to the actual data).
The question is, does anyone (stil) know how to declare such an external
value / string ?
Regards,
Rudy Wieser
this seems to speak of write one dll in tasm
https://tolik-punkoff.com/2022/05/09/writing-win32-programs-in-assembly-language-using-tasm/
here one other link of someone wrote dll in tasm
https://rootbiez.blogspot.com/2010/03/tasm-writing-dll-in-tasm32.html

that question it seems for 2011
Kerr-Mudd, John
2024-04-24 15:47:49 UTC
Permalink
On Wed, 24 Apr 2024 17:10:31 +0200
Post by Rosario19
Post by Rosario19
Post by R.Wieser
Hello all,
I've been using Borlands Tasm32 v5 for a while now, but have a bit of a
problem with declaring strings and values inside a dll.
For instance, CRTDLL.DLL exposes "_iob", which is/should be (a pointer to)
an array of stdio control structures.
And I have no idea how to define it. :-|
Worse: when I checked _IOB points to a "JMP [...]" (indirect jump) byte
sequence (and not a pointer to the actual data).
The question is, does anyone (stil) know how to declare such an external
value / string ?
Regards,
Rudy Wieser
this seems to speak of write one dll in tasm
https://tolik-punkoff.com/2022/05/09/writing-win32-programs-in-assembly-language-using-tasm/
here one other link of someone wrote dll in tasm
https://rootbiez.blogspot.com/2010/03/tasm-writing-dll-in-tasm32.html
that question it seems for 2011
Glad to see your still posting! I'm working on a simple 'frogger' game in
<256 bytes.
--
Bah, and indeed Humbug.
Rosario19
2024-04-26 20:15:37 UTC
Permalink
Post by Kerr-Mudd, John
On Wed, 24 Apr 2024 17:10:31 +0200
Post by Rosario19
Post by Rosario19
Post by R.Wieser
Hello all,
I've been using Borlands Tasm32 v5 for a while now, but have a bit of a
problem with declaring strings and values inside a dll.
For instance, CRTDLL.DLL exposes "_iob", which is/should be (a pointer to)
an array of stdio control structures.
And I have no idea how to define it. :-|
Worse: when I checked _IOB points to a "JMP [...]" (indirect jump) byte
sequence (and not a pointer to the actual data).
The question is, does anyone (stil) know how to declare such an external
value / string ?
Regards,
Rudy Wieser
this seems to speak of write one dll in tasm
https://tolik-punkoff.com/2022/05/09/writing-win32-programs-in-assembly-language-using-tasm/
here one other link of someone wrote dll in tasm
https://rootbiez.blogspot.com/2010/03/tasm-writing-dll-in-tasm32.html
that question it seems for 2011
Glad to see your still posting! I'm working on a simple 'frogger' game in
<256 bytes.
Yes, sometime i game in codegolf but now in C or APL
R.Wieser
2024-04-24 18:01:10 UTC
Permalink
Rosario19,
Post by Rosario19
this seems to speak of write one dll in tasm
[snip]
Post by Rosario19
here one other link of someone wrote dll in tasm
[snip]

Thank you.

But the problem isn't writing them (I've been doing that for a while now),
but accessing values and/or strings stored in other peoples DLLs. Like that
"_iob" in CRTDLL.DLL .

Regards,
Rudy Wieser
JJ
2024-04-25 06:47:14 UTC
Permalink
Post by R.Wieser
Rosario19,
Post by Rosario19
this seems to speak of write one dll in tasm
[snip]
Post by Rosario19
here one other link of someone wrote dll in tasm
[snip]
Thank you.
But the problem isn't writing them (I've been doing that for a while now),
but accessing values and/or strings stored in other peoples DLLs. Like that
"_iob" in CRTDLL.DLL .
Regards,
Rudy Wieser
Assemblers (at least TASM) don't differentiate between external function and
external data. They only see it as external symbol - which can be anything.

Same from the DLLs' perpective, in its PE structure... It has EAT or Export
Address Table (in comparison with IAT or Import Address Table). There's no
no Exported Function Address Table, and there's no Exported Data Address
Table. What's exported/imported is up to the application to interpret, and
it doesn't have to be a function.

So in TASM declare the external symbol as usual. i.e. as if it's a function.
But in the (instructional) code, treat it as a data. After all, functions'
body is not just instructions, but also data (which is treated as
instructions).

Don't use JMP, because you're treating it as a function. Use the OFFSET
directive or LEA instruction instead.

In non ideal circumstances (or weird requirement), JMP _can_ be used, but
that instruction must not be executed. Instead, the instruction's operand
data (which is the address of the import) must be manually read. Same
result, but more roundabout way.
R.Wieser
2024-04-25 10:16:54 UTC
Permalink
JJ,
Post by JJ
Don't use JMP, because you're treating it as a function. Use the
OFFSET directive or LEA instruction instead.
Thats the thing : the OFFSET (or LEA) will *not* return the address of the
pointer to the DLLs data, but to the two-byte indirect-jump instruction
infront of it.

I was hoping that there was a EXTERNAL definition which would account for
those two bytes. Simply said: On definition automatically add 2 to the
value of that label.

Currently I use :

lea eax,[ExternalConstantLabel+2]
mov eax,[eax]

It works well enough, but I have to remember that "+2" every time I use that
particular label.

... Which is just begging me to forget about it (internal labels can be used
as-is) and have my program crash in the most interresting ways :-|

Meh, I just tried to redefine that _iob label using "_iob equ [_iob+2]", but
Tasm didn't like that. Can't really blame it though.

Regards,
Rudy Wieser
Rosario19
2024-04-26 20:10:43 UTC
Permalink
Post by R.Wieser
Rosario19,
Post by Rosario19
this seems to speak of write one dll in tasm
[snip]
Post by Rosario19
here one other link of someone wrote dll in tasm
[snip]
Thank you.
But the problem isn't writing them (I've been doing that for a while now),
but accessing values and/or strings stored in other peoples DLLs. Like that
"_iob" in CRTDLL.DLL .
Regards,
Rudy Wieser
i remember i used
loadlibrary and getprocaddress for
https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getprocaddress

"[in] lpProcName

The function or variable name, or the function's ordinal value. If
this parameter is an ordinal value, it must be in the low-order word;
the high-order word must be zero."
i not remember how...
Rosario19
2024-04-26 20:23:01 UTC
Permalink
Post by Rosario19
Post by R.Wieser
Rosario19,
Post by Rosario19
this seems to speak of write one dll in tasm
[snip]
Post by Rosario19
here one other link of someone wrote dll in tasm
[snip]
Thank you.
But the problem isn't writing them (I've been doing that for a while now),
but accessing values and/or strings stored in other peoples DLLs. Like that
"_iob" in CRTDLL.DLL .
Regards,
Rudy Wieser
i remember i used
loadlibrary and getprocaddress for
https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getprocaddress
"[in] lpProcName
The function or variable name, or the function's ordinal value. If
this parameter is an ordinal value, it must be in the low-order word;
the high-order word must be zero."
i not remember how...
in this link there is a complete example, but in C. I think is
possible in assembly too

https://learn.microsoft.com/en-us/windows/win32/Dlls/using-run-time-dynamic-linking
R.Wieser
2024-04-27 08:11:35 UTC
Permalink
Rosario19,
Post by Rosario19
The function or variable name, or the function's ordinal value.
If this parameter is an ordinal value, it must be in the low-order
word; the high-order word must be zero."
I know, I know. Thats not the problem.

Declaring, in Borlands Tasm32 v5, that external pointer "_iob" to mean
"[_iob+2]" (or even just "_iob+2") is.

Regards,
Rudy Wieser

Loading...