• Borlands Tasm32 v5 and external values (in a DLL)

    From R.Wieser@address@is.invalid to alt.lang.asm on Wed Apr 17 17:40:12 2024
    From Newsgroup: alt.lang.asm

    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


    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Rosario19@Ros@invalid.invalid to alt.lang.asm on Wed Apr 24 16:55:02 2024
    From Newsgroup: alt.lang.asm

    On Wed, 17 Apr 2024 17:40:12 +0200, "R.Wieser" wrote:

    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/

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Rosario19@Ros@invalid.invalid to alt.lang.asm on Wed Apr 24 17:10:31 2024
    From Newsgroup: alt.lang.asm

    On Wed, 24 Apr 2024 16:55:02 +0200, Rosario19 <Ros@invalid.invalid>
    wrote:

    On Wed, 17 Apr 2024 17:40:12 +0200, "R.Wieser" wrote:

    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
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Kerr-Mudd, John@admin@127.0.0.1 to alt.lang.asm on Wed Apr 24 16:47:49 2024
    From Newsgroup: alt.lang.asm

    On Wed, 24 Apr 2024 17:10:31 +0200
    Rosario19 <Ros@invalid.invalid> wrote:

    On Wed, 24 Apr 2024 16:55:02 +0200, Rosario19 <Ros@invalid.invalid>
    wrote:

    On Wed, 17 Apr 2024 17:40:12 +0200, "R.Wieser" wrote:

    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.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From R.Wieser@address@is.invalid to alt.lang.asm on Wed Apr 24 20:01:10 2024
    From Newsgroup: alt.lang.asm

    Rosario19,

    this seems to speak of write one dll in tasm
    [snip]

    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


    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From JJ@jj4public@outlook.com to alt.lang.asm on Thu Apr 25 13:47:14 2024
    From Newsgroup: alt.lang.asm

    On Wed, 24 Apr 2024 20:01:10 +0200, R.Wieser wrote:
    Rosario19,

    this seems to speak of write one dll in tasm
    [snip]

    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.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From R.Wieser@address@is.invalid to alt.lang.asm on Thu Apr 25 12:16:54 2024
    From Newsgroup: alt.lang.asm

    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



    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Rosario19@Ros@invalid.invalid to alt.lang.asm on Fri Apr 26 22:10:43 2024
    From Newsgroup: alt.lang.asm

    On Wed, 24 Apr 2024 20:01:10 +0200, "R.Wieser" wrote:

    Rosario19,

    this seems to speak of write one dll in tasm
    [snip]

    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...
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Rosario19@Ros@invalid.invalid to alt.lang.asm on Fri Apr 26 22:15:37 2024
    From Newsgroup: alt.lang.asm

    On Wed, 24 Apr 2024 16:47:49 +0100, "Kerr-Mudd, John" wrote:

    On Wed, 24 Apr 2024 17:10:31 +0200
    Rosario19 <Ros@invalid.invalid> wrote:

    On Wed, 24 Apr 2024 16:55:02 +0200, Rosario19 <Ros@invalid.invalid>
    wrote:

    On Wed, 17 Apr 2024 17:40:12 +0200, "R.Wieser" wrote:

    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
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Rosario19@Ros@invalid.invalid to alt.lang.asm on Fri Apr 26 22:23:01 2024
    From Newsgroup: alt.lang.asm

    On Fri, 26 Apr 2024 22:10:43 +0200, Rosario19 <Ros@invalid.invalid>
    wrote:

    On Wed, 24 Apr 2024 20:01:10 +0200, "R.Wieser" wrote:

    Rosario19,

    this seems to speak of write one dll in tasm
    [snip]

    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
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From R.Wieser@address@is.invalid to alt.lang.asm on Sat Apr 27 10:11:35 2024
    From Newsgroup: alt.lang.asm

    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


    --- Synchronet 3.21d-Linux NewsLink 1.2