On Tuesday, January 3, 2017 at 8:02:42 PM UTC+3, Jb Evain wrote:
>
> On Sun, Jan 1, 2017 at 6:15 PM, LRN wrote:
>
>> I've used cecil on Windows Runtime metadata files to look at the 
>> interfaces it provides, and was surprised to see that 99% of all types have 
>> AutoLayout attribute. MSDN says[1] that such types must not be accessible 
>> via COM, because their layout is managed by the runtime and is not known at 
>> compile time. Is that true? How do C++ and COM interops work then?
>>
>> [1] https://msdn.microsoft.com/en-us/library/ms182194.aspx
>>
>
> AutoLayout in that case is only important for value types. All reference 
> types will be marked as auto. Are you sure you're looking at value types?
>
Well, i get things like these:
type Windows.System.Threading.TimerElapsedHandler from Windows.System.
Threading namespace
  attributes Public AutoLayout Class Sealed WindowsRuntime AnsiClass
  method .ctor
    attributes CompilerControlled, Private, HideBySig, SpecialName, 
RTSpecialName
    impl attributes Managed, Runtime
    sem attributes None
  method Invoke
    attributes CompilerControlled, Public, Virtual, HideBySig, NewSlot, 
SpecialName
    impl attributes Managed, Runtime
    sem attributes None
type Windows.System.Threading.ThreadPoolTimer from Windows.System.Threading 
namespace
  attributes Public AutoLayout Class Sealed WindowsRuntime AnsiClass
  method get_Period
    attributes CompilerControlled, Public, Final, Virtual, HideBySig, 
NewSlot, SpecialName
    impl attributes Managed, Runtime
    sem attributes Getter
  method get_Delay
    attributes CompilerControlled, Public, Final, Virtual, HideBySig, 
NewSlot, SpecialName
    impl attributes Managed, Runtime
    sem attributes Getter
  method Cancel
    attributes CompilerControlled, Public, Final, Virtual, HideBySig, 
NewSlot
    impl attributes Managed, Runtime
    sem attributes None
  method CreatePeriodicTimer
    attributes CompilerControlled, Public, Static, HideBySig
    impl attributes Managed, Runtime
    sem attributes None
    custom attribute Mono.Cecil.CustomAttribute of type OverloadAttribute
      blob length : 19, header = 1
      blob:
CreatePeriodicTimer
      argument Mono.Cecil.CustomAttributeArgument
  method CreateTimer
    attributes CompilerControlled, Public, Static, HideBySig
    impl attributes Managed, Runtime
    sem attributes None
    custom attribute Mono.Cecil.CustomAttribute of type OverloadAttribute
      blob length : 11, header = 1
      blob:
CreateTimer
      argument Mono.Cecil.CustomAttributeArgument
  method CreatePeriodicTimer
    attributes CompilerControlled, Public, Static, HideBySig
    impl attributes Managed, Runtime
    sem attributes None
    custom attribute Mono.Cecil.CustomAttribute of type OverloadAttribute
      blob length : 33, header = 1
      blob:
CreatePeriodicTimerWithCompletion
      argument Mono.Cecil.CustomAttributeArgument
  method CreateTimer
    attributes CompilerControlled, Public, Static, HideBySig
    impl attributes Managed, Runtime
    sem attributes None
    custom attribute Mono.Cecil.CustomAttribute of type OverloadAttribute
      blob length : 25, header = 1
      blob:
CreateTimerWithCompletion
      argument Mono.Cecil.CustomAttributeArgument
type Windows.System.Threading.IThreadPoolTimer from Windows.System.Threading 
namespace
  attributes NotPublic AutoLayout Interface Abstract WindowsRuntime 
AnsiClass
  method get_Period
    attributes CompilerControlled, Public, Virtual, HideBySig, NewSlot, 
Abstract, SpecialName
    impl attributes IL
    sem attributes Getter
  method get_Delay
    attributes CompilerControlled, Public, Virtual, HideBySig, NewSlot, 
Abstract, SpecialName
    impl attributes IL
    sem attributes Getter
  method Cancel
    attributes CompilerControlled, Public, Virtual, HideBySig, NewSlot, 
Abstract
    impl attributes IL
    sem attributes None
type Windows.System.Threading.IThreadPoolTimerStatics from Windows.System.
Threading namespace
  attributes NotPublic AutoLayout Interface Abstract WindowsRuntime 
AnsiClass
  method CreatePeriodicTimer
    attributes CompilerControlled, Public, Virtual, HideBySig, NewSlot, 
Abstract
    impl attributes IL
    sem attributes None
    custom attribute Mono.Cecil.CustomAttribute of type OverloadAttribute
      blob length : 19, header = 1
      blob:
CreatePeriodicTimer
      argument Mono.Cecil.CustomAttributeArgument
  method CreateTimer
    attributes CompilerControlled, Public, Virtual, HideBySig, NewSlot, 
Abstract
    impl attributes IL
    sem attributes None
    custom attribute Mono.Cecil.CustomAttribute of type OverloadAttribute
      blob length : 11, header = 1
      blob:
CreateTimer
      argument Mono.Cecil.CustomAttributeArgument
  method CreatePeriodicTimer
    attributes CompilerControlled, Public, Virtual, HideBySig, NewSlot, 
Abstract
    impl attributes IL
    sem attributes None
    custom attribute Mono.Cecil.CustomAttribute of type OverloadAttribute
      blob length : 33, header = 1
      blob:
CreatePeriodicTimerWithCompletion
      argument Mono.Cecil.CustomAttributeArgument
  method CreateTimer
    attributes CompilerControlled, Public, Virtual, HideBySig, NewSlot, 
Abstract
    impl attributes IL
    sem attributes None
    custom attribute Mono.Cecil.CustomAttribute of type OverloadAttribute
      blob length : 25, header = 1
      blob:
CreateTimerWithCompletion
      argument Mono.Cecil.CustomAttributeArgument

And what i need to get looks something like this - 
https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-headers/include/windows.system.threading.idl
Basically, i want to create all the missing idl files in mingw-w64 by 
reading Windos Runtime metadata and then turn these idl files into C 
headers to be able to use WinRT in C via COM.
For obvious reasons, i have to be sure that the order of method pointers in 
Vtbl structs is correct and does not change at runtime. Not sure about 
actual structs, like TimeSpan or SortEntry; TimeSpan only has one field, 
but according to Windows SDK SortEntry must look like this:
struct __x_ABI_CWindows_CStorage_CSearch_CSortEntry
    {
    HSTRING PropertyName;
    boolean AscendingOrder;
    } ;
So, does AutoLayout influence the order (and offset?) of vtbl pointers? And 
structs?


-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to