Windows 8 (7955) Findings in M3 Leak

Discussion in 'Windows 8' started by spion, Apr 26, 2011.

  1. bored_neo

    bored_neo MDL Junior Member

    Jun 3, 2011
    53
    26
    0
    #181 bored_neo, Jun 10, 2011
    Last edited by a moderator: Apr 20, 2017
    Not exactly an "immersive window" but here's how you can get to see a Jupiter window:

    Code:
    struct HSTRING_HEADER {
    char unknown[20];
    };
    
    struct HString {
    HSTRING_HEADER *ptr;
    };
    
    struct HStringRef {
    HSTRING_HEADER *ref;
    HSTRING_HEADER hstr;
    };
    
    typedef HRESULT (__stdcall *pWinRTInitialize)(int);
    typedef HRESULT (__stdcall *pWinRTActivateInstance)(void *, void **);
    typedef HRESULT (__stdcall *pWindowsCreateStringReference)(wchar_t *, int, void *, void *);
    
    class IUnknown {
    public:
    virtual HRESULT __stdcall QueryInterface(const IID &, void **) = 0;
    virtual ULONG __stdcall AddRef() = 0;
    virtual ULONG __stdcall Release() = 0;
    };
    
    class IInspectable : public IUnknown {
    public:
    virtual HRESULT __stdcall GetIids(int *count, IID **ifaces);
    virtual HRESULT __stdcall GetRuntimeClassName(HString *);
    virtual HRESULT __stdcall GetTrustLevel(int *);
    };
    
    class IApplication : public IInspectable {
    public:
    virtual HRESULT __stdcall f0();
    virtual HRESULT __stdcall f1();
    virtual HRESULT __stdcall f2();
    virtual HRESULT __stdcall f3();
    virtual HRESULT __stdcall f4();
    virtual HRESULT __stdcall f5();
    virtual HRESULT __stdcall Run();
    };
    
    int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
    {
    HMODULE winrt = LoadLibrary(L"combase.dll");
    
    pWinRTInitialize WinRTInitialize = reinterpret_cast<pWinRTInitialize>(GetProcAddress(winrt, "WinRTInitialize"));
    pWinRTActivateInstance WinRTActivateInstance = reinterpret_cast<pWinRTActivateInstance>(GetProcAddress(winrt, "WinRTActivateInstance"));
    pWindowsCreateStringReference WinCreateStringReference = reinterpret_cast<pWindowsCreateStringReference>(GetProcAddress(winrt, "WindowsCreateStringReference"));
    
    HRESULT hr = WinRTInitialize(0);
    
    HStringRef appClassName;
    
    WinCreateStringReference(L"Windows.UI.DirectUI.Application", wcslen(L"Windows.UI.DirectUI.Application"), 
    &appClassName.hstr, &appClassName.ref);
    
    IInspectable *unkn;
    hr = WinRTActivateInstance(appClassName.ref, reinterpret_cast<void **>(&unkn));
    
    GUID *ifaces;
    int count;
    unkn->GetIids(&count, &ifaces);
    
    IApplication *app;
    hr = unkn->QueryInterface(ifaces[0], reinterpret_cast<void **>(&app));
    
    hr = app->Run();
    
    return 0;
    }
    
    Unfortunately I can't figure out how to load some XAML in that window...
     
  2. NaiveUser

    NaiveUser MDL Senior Member

    Apr 14, 2011
    419
    523
    10
    #182 NaiveUser, Jun 10, 2011
    Last edited by a moderator: Apr 20, 2017
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. maverin

    maverin MDL Novice

    Jun 10, 2011
    6
    0
    0
    Can you post / attach the twinapi.dll file? (or wherever Windows.UI.DirectUI is held) So perhaps we can get a type library out of it, see what else it exposes?

    - maverin
     
  4. NaiveUser

    NaiveUser MDL Senior Member

    Apr 14, 2011
    419
    523
    10
    #184 NaiveUser, Jun 10, 2011
    Last edited by a moderator: Apr 20, 2017
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. NaiveUser

    NaiveUser MDL Senior Member

    Apr 14, 2011
    419
    523
    10
    #185 NaiveUser, Jun 11, 2011
    Last edited by a moderator: Apr 20, 2017
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. maverin

    maverin MDL Novice

    Jun 10, 2011
    6
    0
    0
    So how much of DirectUI is specific to Windows 8? Isn't it the same UI library used by msn messenger etc.?
    eg.
    visualstudiogallery.msdn.microsoft.com/1B69C9FE-E422-4799-9EB5-6AC7034C52E1

    - maverin
     
  7. jmorrill

    jmorrill MDL Novice

    Jun 11, 2011
    1
    0
    0
    Great work NaiveUser. If you felt inclined, could you show us the loaded DLLs in that process using something like Process Explorer (I'd post a link to it but I'm a new user!). I'd be interested what D3D version is being used and if D2D is being loaded too :).

    Thanks!
     
  8. evilbringer

    evilbringer MDL Novice

    Apr 27, 2011
    30
    1
    0
    all I can see and read is :blahblah1:

    of course, I'm grumpy since its midnight here :D
     
  9. NaiveUser

    NaiveUser MDL Senior Member

    Apr 14, 2011
    419
    523
    10
    HAHAH I just realized that I can actually use async/await in my C# code now ! YEAH !
    and there is System.Runtime.InteropServices.WindowsRuntime namespace inside mscorlib.
    and there is System.Runtime.WindowsRuntime.dll and System.Threading.Tasks.Dataflow.dll, which are new to 4.5.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. NaiveUser

    NaiveUser MDL Senior Member

    Apr 14, 2011
    419
    523
    10
    well I dont think DirectUI.dll is directly related to the 'DirectUI' in DUI70.DLL/DUSER.DLL now, there is no much clue about the connection btween them. I used to think they are related because of the same name, but it turns out not the case. see the discussions in #166 of this thread.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. NaiveUser

    NaiveUser MDL Senior Member

    Apr 14, 2011
    419
    523
    10
    #191 NaiveUser, Jun 12, 2011
    Last edited by a moderator: Apr 20, 2017
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. maverin

    maverin MDL Novice

    Jun 10, 2011
    6
    0
    0
    What about when you call CreateImmersiveWindow - what class is the HWND that creates, any idea? Just wondering if it might offer a clue as to whether this is related to the old DirectUIHWND stuff.

    - maverin
     
  13. maverin

    maverin MDL Novice

    Jun 10, 2011
    6
    0
    0
    I'll also be interested to see if you can find any kind of references to trident integration in this.. or any HTML DOM references in DirectUI. I'm assuming that Jupiter has a closer integration with HTML than we've heard so far... at least if you were to believe the MS guys giving the demos. Or perhaps the integration is the other way around - that we'll have some proprietary tag in IE10 to include some of this xaml.

    - maverin
     
  14. NaiveUser

    NaiveUser MDL Senior Member

    Apr 14, 2011
    419
    523
    10
    the window class name is the second parameter of CreateImmsersiveWindow, I used 'EDIT' in my demo, other apps use their own classes they registered themselves. and I remember I have messed it up with my own WNDCLASSEX, well, maybe I will try that later.

    I think the 'Immersive Window' thing is a low-level Win32 window management concept, and its not related to any specific UI toolkit or framework, to you its just a HWND.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. ctxsnstv

    ctxsnstv MDL Novice

    Jun 12, 2011
    8
    0
    0
    #195 ctxsnstv, Jun 12, 2011
    Last edited: Jun 12, 2011
    about async/await, in the WinStore JavaScript code you posted there were some XXXAsync
    methods which were called through WinRT from JS, and apparently were designed to take JS closures/functions as callback parameters, which is cool as I don't think you could do that through ActiveX. What would be REALLY cool though is if there were some magic in the .NET interop with WinRT that let you "await" on WinRT methods using this convention. Then you could have one async WinRT method that could be called using idiomatic async conventions in JavaScript, C#/VB, and C++ (? not sure what the modern convention would be here ...)

    Is there anything like that or am I just dreaming?
     
  16. NaiveUser

    NaiveUser MDL Senior Member

    Apr 14, 2011
    419
    523
    10
    nope. but I guess you can create any WinRT object with JavaScript in your 'native' Windows Web Application, so in theory you might be able to mix your HTML5 app with DirectUI in someway, not sure why you want to do this though.

    and as I said before, the Browser Programmability and Tools team is building RAD framework for HTML5/JavaScript, with VS/Blend tooling support.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. NaiveUser

    NaiveUser MDL Senior Member

    Apr 14, 2011
    419
    523
    10
    well, AFAIK the 'await' in C#/VB language is just a compiler magic for a pattern, you should be able to await anything that have GetAwaiter/BeginAwait/EndAwait pattern, so you might be able to create awaitable type in WinRT I guess. the actual behaviour depends on your implementation though, maybe you can leverage the upcoming task/continuation library in Concurrency Runtime to do it.

    but JavaScript/C++ ? not sure about that.

    P.S. noticed two more new assemblies in GAC: System.Reflection.Production and System.Runtime.Serialization.OData
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. bored_neo

    bored_neo MDL Junior Member

    Jun 3, 2011
    53
    26
    0
    I suspect not quite "any WinRT object". Some WinRT objects have a WebHostHiddenAttribute, in particular all DirectUI classes have this attribute so....
     
  19. ctxsnstv

    ctxsnstv MDL Novice

    Jun 12, 2011
    8
    0
    0
    #199 ctxsnstv, Jun 12, 2011
    Last edited by a moderator: Apr 20, 2017
    I guess I'm a bit confused about what WinRT really is. If WinRT "typelibs" are just .NET assemblies, does that mean WinRT libs can use the entire CLR type system in their contracts, including generics for example? And then would I still be able to call them from JavaScript? Or are the features supported by WinMD files/WinTypes.DLL just a subset of the CLR type system features?

    how does something like
    Code:
        // Feature methods
        this.Feature_GetAppInfoAsync = function (args) {
            var feature = this.nativeOM.Feature;
            feature.GetAppInfoAsync(args.featureType, args.featureId,
                                    function (oAppInfo) {
                                        args.returnValue = MarshalAppInfo(oAppInfo);
                                        document.frames[0].postMessage(JSON.stringify(args), "*");
                                    });
        };
    pass in the JS function as the third argument to the native OM's GetAppInfoAsync? is the type of the third argument just a CLR delegate?
     
  20. NaiveUser

    NaiveUser MDL Senior Member

    Apr 14, 2011
    419
    523
    10
    #200 NaiveUser, Jun 12, 2011
    Last edited by a moderator: Apr 20, 2017
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...