Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#6 FindProcDll and Latent Error

closed
nobody
None
5
2007-02-28
2006-11-17
hobbyscripter
No

Hi, Dear Project Developer,

After reading the code of FindProcDLL, i found that it is considered DANGEROUS that we use "pop $R0" command to get the return value. Because FindProcDLL will write the return value DIRECTLY to $R0 instead of pushing the return value to stack.

This may cause problem when you leave some data in the stack.

A nice solution is to use a macro to wrap FindProcDLL::FindProc function.

; =====MACRO-BLOCK-START=====
!macro FindProc _RETURN_VAR _PROC_NAME
Push $R0 ; [STACK] << $R0
FindProcDLL::FindProc "${_PROC_NAME}"
Exch $R0 ; [STACK] << [RETURN_VALUE]
Pop ${_RETURN_VAR} ; ${_RETURN_VAR} = [RETURN_VALUE]
!macroend
!define FindProc "!insertmacro FindProc"
; =====MACRO-BLOCK-END=====

And use command:

; =====CODE-EXAMPLE-BLOCK-START=====
${FindProc} [RETURN_VALUE] [PROC_NAME]
;e.g. ${FindProc} $R0 "firefox.exe"
; =====CODE-EXAMPLE-BLOCK-END=====

Hope this is helpful!

Regards,
_______________hobbyscripter

Discussion

  • John T. Haller
    John T. Haller
    2007-02-28

    Logged In: YES
    user_id=1176140
    Originator: NO

    fixed in current releases

     
  • John T. Haller
    John T. Haller
    2007-02-28

    • status: open --> closed