I'm having problems with this,. I've searched lots of tutorials but for something that is rather basic, I can't seem to find it.
this is completely wrong, but perhaps you can figure out my intention
---masm32--
EXPORTS GetWhatisDLLDoing
.data
gc_Thread_GameMoniter db 'Thread_GameMoniter',0
gc_Thread_HideModule db 'Thread_HideModule',0
gc_Thread_PipeMoniter db 'Thread_PipeMoniter',0
.data?
szWhatisDLLDoing db 255 dup (?)
.code
GetWhatisDLLDoing proc txtline:LPSTR
mov txtline,Offset gc_Thread_PipeMoniter
ret
GetWhatisDLLDoing endp
----------vb---
Private Declare Function GetWhatisDLLDoing Lib "mylib" (ByRef txtline As String)
---
basically, I'm trying to probe certain behaviour from this dll. I'm trying to copy the constant text into into a dynamic buffer, then return the value to the vb calling program
OTOH, if you also have ways of how to update a listbox or a txtbox in vb from the dll, let me know.
obviously this isn't it either.. (which I got from asmintro.hlp )
GetWhatisDLLDoing proc CmdLine:LPSTR
cld ; clear direction flag to read forward
mov esi, Offset gc_Thread_PipeMoniter ; put address into the source index
mov edi, CmdLine ; put address into the destination index
mylabel:
lodsb ; load byte from source into AL and inc ESI
stosb ; write AL to dest and inc EDI
cmp al, 0 ; see if its an ascii zero
jne mylabel ; read the next byte if its not
ret
GetWhatisDLLDoing endp
Greetings,
Why not declare the function as returning a string:
Private Declare Function GetWhatisDLLDoing Lib "mylib" () as String
Then simply mov the corresponding offset into EAX then ret?:
GetWhatisDLLDoing proc
mov eax, Offset gc_Thread_PipeMoniter
ret
GetWhatisDLLDoing endp
Regards,
Tim
ooh. thanks.
--
also, would you know of any function lying around that writes to log file?
I've got one example but its rather messed up. (and may not be the most elegant of examples)
Technically, for the strings, you should allocate a BSTR. You can do that with the SysAllocString* range of functions. If you have an ANSI string (8-bits per character), get the length and use SysAllocStringByteLen. If you have a wide-character (16-bits per character) you can use SysAllocString. VB strings are stored internally as wide-characters but VB converts them to ANSI when they are passed to external functions. If you start doing that, ByVal will pass a pointer to the string while ByRef will pass a pointer to the pointer to the string.
For a listbox/textbox simply pass the hWnd property out. There's very little (if any) advantage to this, and it's generally 'more polite' to let the VB program handle it's GUI.
Cheers,
Zooba :U