Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Passing Pointers to a dll

Gavin86Gavin86 Member Posts: 1
I have this program that i'm trying to make. It requires me to pass information to the DLL i'm using as a pointer:

FFSound_Load
============
* the first is a pointer to an array of bytes (the ROM... area $34010-$38010)
*the second is another pointer to an array of bytes (the ROM... area $3C010-$40010)


apparently the code in C looks like this (someone coded the dll for me, as i don't know C or nearly enough to make what i needed):
===========
"void DLLEXPORT FFSound_Load(BYTE* pFront,BYTE* pRear);"



and i declared it in VB like so:
===========
"Public Declare sub FLoad Lib "FFSound.dll" Alias "FFSound_Load" (pFront
as byte, pRear as byte)"




i'll be loading specific portions of a .NES file into an array, lets just call it bytNESfile(0 to WhateverSize)....

now i need to pass what address in the RAM the loaded array takes up...

i really have no idea if that makes sense or not, but i hope it does -_-. And more: i hope there is a solution :P

Comments

  • DjSpiritDjSpirit Member Posts: 371
    : I have this program that i'm trying to make. It requires me to pass information to the DLL i'm using as a pointer:
    :
    : FFSound_Load
    : ============
    : * the first is a pointer to an array of bytes (the ROM... area $34010-$38010)
    : *the second is another pointer to an array of bytes (the ROM... area $3C010-$40010)
    :
    :
    : apparently the code in C looks like this (someone coded the dll for me, as i don't know C or nearly enough to make what i needed):
    : ===========
    : "void DLLEXPORT FFSound_Load(BYTE* pFront,BYTE* pRear);"
    :
    :
    :
    : and i declared it in VB like so:
    : ===========
    : "Public Declare sub FLoad Lib "FFSound.dll" Alias "FFSound_Load" (pFront
    : as byte, pRear as byte)"
    :
    :
    :
    :
    : i'll be loading specific portions of a .NES file into an array, lets just call it bytNESfile(0 to WhateverSize)....
    :
    : now i need to pass what address in the RAM the loaded array takes up...
    :
    : i really have no idea if that makes sense or not, but i hope it does -_-. And more: i hope there is a solution :P
    :
    [grey]I think you have gotten the function correct but for clarification I will give it again here in a somewhat more explaining form:
    Public Declare Sub FLoad Lib "FFSound.dll" Alias "FFSound_Load" (ByRef pFront As Byte, ByRef pRear As Byte)

    The ByRef here is key because it causes vb to pass the pointer of the variable to the function, instead of the byte itself.
    The ByRef's aren't really neccesary in VB6 because it's the standard way for vb to handle arguments, however for vb.net this is no longer true, and also it makes for more readable code.

    If you want to pass an arrray to this subprocedure you _must_ remember to pass the first element of the array and not the array itself. This because of how vb handles arrays. So the calling would be something like this:
    FLoad bytNESfile(0), bytOtherArray(0)

    You could also declare your function like this:
    Public Declare Sub FLoad Lib "FFSound.dll" Alias "FFSound_Load" (ByVal pFront As Long, ByVal pRear As Long)

    Then you would have to call it like this:
    FLoad VarPtr(bytNESfile(0)), VarPtr(bytOtherArray(0))

    DjSpirit, probably as beautiful as the fairy in the tower in the dark world of Zelda3 8).[/grey]

Sign In or Register to comment.