Hello, I have this code:

.data
xd db "jjjj",0
      .code

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

LibMain proc instance:DWORD,reason:DWORD,unused:DWORD 

    .if reason == DLL_PROCESS_ATTACH

push dword ptr ds:[ xd]
call Teste
      mov eax, TRUE                 ; return TRUE so DLL will start

    .elseif reason == DLL_PROCESS_DETACH

    .elseif reason == DLL_THREAD_ATTACH

    .elseif reason == DLL_THREAD_DETACH

    .endif

    ret

LibMain endp

Teste proc T
        invoke MessageBox, NULL, addr T, addr T, MB_OK
        ret 

Teste endp

But, the messagebox, after the "jjj" text, there is some weird characters.
How to fix it?

Recommended Answers

All 2 Replies

What your doing is passing the address of the proceedure to MesssageBox instead of xd

invoke  MessageBox, NULL, addr xd, addr xd, MB_OK.

It will look kid of odd those, your caption being exactly the same as text

Also, since the address of xd is known at assembly time you can do:

invoke	MessageBox, NULL, offset xd, offset xd, MB_OK

or

push	MB_OK
	push	offset xd
	push	offset xd
	push	NULL
	call	MessageBox
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.