CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: DLL help

  1. #1
    Join Date
    Sep 2005
    Posts
    1

    DLL help

    Here is the code I have so far...

    ; MessageBox DLL
    format PE GUI 4.0 DLL
    entry DllEntryPoint
    include 'INCLUDE\win32a.inc'
    section '.data' data readable writeable
    result db "Return this",0
    section '.code' code readable executable

    proc DllEntryPoint, hinstDLL,fdwReason,lpvReserved
    mov eax,TRUE
    ret
    endp


    ;Message Proc
    proc message, title, text
    invoke MessageBox,NULL,[text],[title],MB_OK
    movq eax,result
    ret
    endp


    section '.idata' import data readable writeable
    library user,'USER32.DLL'
    import user,\
    MessageBox,'MessageBoxA'
    section '.edata' export data readable
    export 'message.DLL',\
    message, 'message';Export function,name
    section '.reloc' fixups data discardable





    But I need the return value of proc message to be a 64 bit value but it returns it has 32 bit.

    This is the part I need help with:

    ;Message Proc
    proc message, title, text
    invoke MessageBox,NULL,[text],[title],MB_OK
    movq eax,result
    ret
    endp


    I need to convert eax to a 64 bit value but I got now clue how, or if that doesn't work how would I get a 64 bit value?

  2. #2
    Join Date
    Nov 2004
    Posts
    34

    Re: DLL help

    Quote Originally Posted by Rune Hunter
    Here is the code I have so far...
    ;Message Proc
    proc message, title, text
    invoke MessageBox,NULL,[text],[title],MB_OK
    movq eax,result
    ret
    endp


    I need to convert eax to a 64 bit value but I got now clue how, or if that doesn't work how would I get a 64 bit value?

    You can't return a 64 bit value into a 32 bit register. MOVQ (and MOVD) are designed to be used with MMX registers.

    If you must return a 64 bit value and can't use MMX, then you can go with 2 options:

    return in 2 32 bit reigsters; eg: EDX/EAX
    or return a reference of 'result' in EAX (assuming 'result' is a memory location that will remain valid upon return from the procedure.

    So, to return the address of 'result' in eax, use:

    mov eax, result

    Then to access it:

    [eax + 0 ] for low order dword
    [eax + 4 ] for high order dword

    -sevagK
    www.geocities.com/kahlinor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured