Einzelnen Beitrag anzeigen

Apollonius

Registriert seit: 16. Apr 2007
2.325 Beiträge
 
Turbo Delphi für Win32
 
#17

Re: D3D9 Hook bzw. als "proxy.dll"

  Alt 27. Okt 2009, 21:40
Delphi doesn't really put the result on stack - it uses an out Parameter. You see that the calling routine pushes the address ebp - 8 which is the address of the Unknown variable.
I think that the modified signature using an out-parameter instead of the usual result is reasonable from a design standpoint. Returning an interface in eax is always bad - and never happens in the usual COM context - because it poses a severe problem with respect to exception handling. If an exception occurs when the called routine returns, the interface cannot be released correctly because it is lost when the exception is thrown. Using the Delphi design, on the other hand, the caller retains a reference to the interface and will release it due to the auto-generated try-finally.
To sum it up, the Delphi semantics is different to the C++ semantics and perhaps different from naive expectations, but it is the best way to do it in my opinion. The error is on the side of the Direct3D developers because they designed their function to break COM rules.
Wer erweist der Welt einen Dienst und findet ein gutes Synonym für "Pointer"?
"An interface pointer is a pointer to a pointer. This pointer points to an array of pointers, each of which points to an interface function."
  Mit Zitat antworten Zitat