|
-
Oct 26th, 2001, 01:03 PM
#1
I need help Guys (Code inside)
OOkay, I'm making a DLL (using MASM32). The dll simpley displays a message box.. pretty simple.. I used it from VB, and it worked fine, displayed the messagebox and everything.. Now this is the problem, I changed the source, I want to be able to pass a string value from VB, and the DLL should show a message box with the string that i sent it.. this is the code that I have right now, but all i get is garbage on the message box, the same garbage, it doesn't change or anything....
So once again this is what I'm trying to do:
Pass a string value like so: TestFunction("BlahBlahBLah")
and i want the dll to give a message box with the text BlahBlahBLah.. get what I"m saying? I hope you do.. please someone help lol...
Code:
.386
.model flat,stdcall
option casemap:none
;####################################################
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
;####################################################
.data
AppName db "MAIN DLL FROM FALCY",0
MainMessage db "Hi, This is the message from TestFunction Procedure",0
.data?
MoreMessage LPSTR ?
.code
DllEntry proc hinstDLL:HINSTANCE,reason:DWORD,reserved1:DWORD
mov eax,TRUE
ret
DllEntry Endp
TestFunction proc BlahString:LPSTR
push BlahString
pop eax
mov MoreMessage,eax
push MB_OK
push offset AppName
push offset MoreMessage
push 0
Call MessageBox
ret
TestFunction endp
End DllEntry
-
Oct 29th, 2001, 01:03 AM
#2
Junior Member
2 things
from VB you need to go ByVal("blah") or SADD("blah") or something like that
also, in the dll you say
Code:
push offset MoreMessage
when you mean
or even simpler you could go
Code:
push MB_OK
push offset AppName
push BlahString
push 0
Call MessageBox
remember that you are getting the offset of the string already
-
Oct 29th, 2001, 10:01 PM
#3
Another thing to think about is that VB strings are UNICODE, which means that each character is 2 bytes long, instead of the normal 1 byte. They also have a header in front of the string data istelf, to give information about the length of the string. I dont remember exactly how long the header is though.
Z.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|