Recent

Author Topic: Possible error in ActiveX interface definition  (Read 15248 times)

440bx

  • Hero Member
  • *****
  • Posts: 4727
Possible error in ActiveX interface definition
« on: April 03, 2024, 12:57:51 am »
Hello,

In ActiveX.pp IEnumMoniker is defined as follows:
Code: Pascal  [Select][+][-]
  1.     IEnumMoniker = Interface (IUnknown)
  2.        ['{00000102-0000-0000-C000-000000000046}']
  3.        Function Next(celt:ULong; out Elt;out celftfetched: ULong):HResult; StdCall;
  4. //     Function RemoteNext(Celt:ULong; Out rgelt;out celtfetched :ULong):Hresult; StdCall;
  5.        Function Skip(celt:Ulong):HResult; StdCall;
  6.        Function Reset:HResult; StdCall;
  7.        Function Close(out penum:IEnumMoniker):HResult;StdCall;
  8.        End;
  9.  
Note the name of the last method in that definition is "Close".

in objidl.h the C++ definition of the class is
Code: C  [Select][+][-]
  1. MIDL_INTERFACE("00000102-0000-0000-C000-000000000046")
  2.     IEnumMoniker : public IUnknown
  3.     {
  4.     public:
  5.         virtual /* [local] */ HRESULT STDMETHODCALLTYPE Next(
  6.             /* [in] */ ULONG celt,
  7.             /* [annotation] */
  8.             _Out_writes_to_(celt,*pceltFetched)  IMoniker **rgelt,
  9.             /* [annotation] */
  10.             _Out_opt_  ULONG *pceltFetched) = 0;
  11.        
  12.         virtual HRESULT STDMETHODCALLTYPE Skip(
  13.             /* [in] */ ULONG celt) = 0;
  14.        
  15.         virtual HRESULT STDMETHODCALLTYPE Reset( void) = 0;
  16.        
  17.         virtual HRESULT STDMETHODCALLTYPE Clone(
  18.             /* [out] */ __RPC__deref_out_opt IEnumMoniker **ppenum) = 0;      
  19.     };
Note the name of the last method is "Clone" not "Close" as it appears in the Pascal definition.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

dsiders

  • Hero Member
  • *****
  • Posts: 1280
Re: Possible error in ActiveX interface definition
« Reply #1 on: April 03, 2024, 01:32:17 am »
Hello,

In ActiveX.pp IEnumMoniker is defined as follows:
Code: Pascal  [Select][+][-]
  1.     IEnumMoniker = Interface (IUnknown)
  2.        ['{00000102-0000-0000-C000-000000000046}']
  3.        Function Next(celt:ULong; out Elt;out celftfetched: ULong):HResult; StdCall;
  4. //     Function RemoteNext(Celt:ULong; Out rgelt;out celtfetched :ULong):Hresult; StdCall;
  5.        Function Skip(celt:Ulong):HResult; StdCall;
  6.        Function Reset:HResult; StdCall;
  7.        Function Close(out penum:IEnumMoniker):HResult;StdCall;
  8.        End;
  9.  
Note the name of the last method in that definition is "Close".

in objidl.h the C++ definition of the class is
Code: C  [Select][+][-]
  1. MIDL_INTERFACE("00000102-0000-0000-C000-000000000046")
  2.     IEnumMoniker : public IUnknown
  3.     {
  4.     public:
  5.         virtual /* [local] */ HRESULT STDMETHODCALLTYPE Next(
  6.             /* [in] */ ULONG celt,
  7.             /* [annotation] */
  8.             _Out_writes_to_(celt,*pceltFetched)  IMoniker **rgelt,
  9.             /* [annotation] */
  10.             _Out_opt_  ULONG *pceltFetched) = 0;
  11.        
  12.         virtual HRESULT STDMETHODCALLTYPE Skip(
  13.             /* [in] */ ULONG celt) = 0;
  14.        
  15.         virtual HRESULT STDMETHODCALLTYPE Reset( void) = 0;
  16.        
  17.         virtual HRESULT STDMETHODCALLTYPE Clone(
  18.             /* [out] */ __RPC__deref_out_opt IEnumMoniker **ppenum) = 0;      
  19.     };
Note the name of the last method is "Clone" not "Close" as it appears in the Pascal definition.

Strangely enough, the declaration is correct in packages/winunits-jedi/src/jwaactivex.pas.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

440bx

  • Hero Member
  • *****
  • Posts: 4727
Re: Possible error in ActiveX interface definition
« Reply #2 on: April 03, 2024, 01:36:07 am »
Strangely enough, the declaration is correct in packages/winunits-jedi/src/jwaactivex.pas.
I've noticed in a number of occasions that the JEDI units tend to be more "accurate".  Looks like there was more manual effort involved in their translation.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 16139
  • Censorship about opinions does not belong here.
Re: Possible error in ActiveX interface definition
« Reply #3 on: April 03, 2024, 07:38:01 am »
It may well be the other way around.This looks more like a typo.
Anyway, that is one of the reasons I still use the D2007/D7 type library importers over the FreePascal one.
If I smell bad code it usually is bad code and that includes my own code.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11930
  • FPC developer.
Re: Possible error in ActiveX interface definition
« Reply #4 on: April 03, 2024, 09:30:14 am »
Strangely enough, the declaration is correct in packages/winunits-jedi/src/jwaactivex.pas.
I've noticed in a number of occasions that the JEDI units tend to be more "accurate".  Looks like there was more manual effort involved in their translation.

IMHO too generalised a statement, and frankly speaking, unfair.   To start with, the original Windows unit and later additions and the various parts of winunits-base all have different history with how the conversion was done (e.g. the original nineties semi automatic windows unit conversion garbled comments and used a lot of VAR). Later conversions learned from the gotchas of the earlier ones.

JEDI's would have had many, many more eyes in the early days, so more initial errors in core units would have been solved. They might have also compared to the Borland units, as they were not as concerned with copyright. But also there some units were earlier converted and more used than others. But the worst thing is that FPC tried to get things 64-bit clean much earlier, and Jedi still were targeting D7.

440bx

  • Hero Member
  • *****
  • Posts: 4727
Re: Possible error in ActiveX interface definition
« Reply #5 on: April 03, 2024, 09:48:38 am »
IMHO too generalised a statement, and frankly speaking, unfair.
It wasn't and isn't my intention to be unfair but, in your own words:

JEDI's would have had many, many more eyes in the early days, so more initial errors in core units would have been solved. They might have also compared to the Borland units, as they were not as concerned with copyright.
I think those statements of yours confirm what I stated in my previous post.

OTH, I think the JEDI folks aren't the only ones who compared their ports to the Borland definitions.  There are some definitions in the FPC API units that are "uncanningly" similar to the Borland ones, though the similarities may be a result of forced compatibility and not direct comparisons of the definitions.

At this point, it may be appropriate to point out that in the great majority of civilized countries, specifications, which includes API definitions, are _not_ protected by copyright.   To be crystal clear, looking at Borland's API definitions to ensure FPC's are compatible would not constitute a copyright violation.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11930
  • FPC developer.
Re: Possible error in ActiveX interface definition
« Reply #6 on: April 03, 2024, 09:57:08 am »
OTH, I think the JEDI folks aren't the only ones who compared their ports to the Borland definitions.  There are some definitions in the FPC API units that are "uncanningly" similar to the Borland ones, though the similarities may be a result of forced compatibility and not direct comparisons of the definitions.

Sometimes corrections in bugreports give an insight in Borland style, and that is then propogated to related code. 

Quote
At this point, it may be appropriate to point out that in the great majority of civilized countries, specifications, which includes API definitions, are _not_ protected by copyright.   To be crystal clear, looking at Borland's API definitions to ensure FPC's are compatible would not constitute a copyright violation.

It might be worth pointing out that while that is a legal right, actually defending against a cease and desist is more difficult. The problem is that copyright holders are somewhat bound to investigate copyright claims (if they have a habit of not, it can be used against them)

So what happens is they might commission some eager IP lawyer firm to investigate who, with minimal effort and maximal billing, might run some similarity software and produce "grounds for a cease and desist" without much nuance (like they come from the same MS headers).

Then your options are only to rip the disputed code out at tremendous (labour) cost (effectively do it anew, clean room), or put up your house to pay for a US legal defence. And as for the old nugget "just never go to the US", ask Julian Assange for his opinion.

(later: reworked long sentences a bit)
« Last Edit: April 03, 2024, 01:57:18 pm by marcov »

Thaddy

  • Hero Member
  • *****
  • Posts: 16139
  • Censorship about opinions does not belong here.
Re: Possible error in ActiveX interface definition
« Reply #7 on: April 03, 2024, 10:02:52 am »
I wouldn't use nugget, but adage, which has a nice ring to Assange.
If I smell bad code it usually is bad code and that includes my own code.

 

TinyPortal © 2005-2018