Dynamic code execution on WinRT in Windows 8 (either C++ or .NET/C#)?

后端 未结 9 1356
谎友^
谎友^ 2021-01-02 04:12

Does WinRT under windows 8 metro allow you to dynamically load and execute code? For example, is it possible to download a dll into memory or to isolated storage and run cod

相关标签:
9条回答
  • 2021-01-02 04:32

    In general, you cannot load and execute new code in a Metro style app. What you can access is what you ship with the app.

    LoadLibrary and GetProcAddress are missing so C++ can't dynamically load code.
    Likewise, C# cannot because there is no Assembly.Load.
    JavaScript can, but only in the web container and not in the fuller trust portions of the code.

    The reason for all this is that the store's security/malware protection would be moot if an app could just load and run arbitrary code.

    0 讨论(0)
  • 2021-01-02 04:36

    Does WinRT under windows 8 metro allow you to dynamically load and execute code?

    No.

    For example, is it possible to download a dll into memory or to isolated storage and run code from it?

    No.

    Could code that JIT compiles a scripting language to native assembly language (e.g. third party browsers) be able to do the same in WinRT, or is it prohibited as an "unsafe" operation?

    It would be prohibited.

    Is the answer to this question different for "managed" code running in WinRT?

    No.

    For example, in managed code, could you download an assembly from the internet and have it be discoverable in MEF or otherwise be able to load it at runtime?

    No.

    Can you use Reflection.Emit in some form?

    No.

    In C++, can you run assembly code generated at runtime by your application, or dynamically load a DLL at runtime (presumably some form of WinRT DLL)?

    No.

    Everything you described would allow the safety guarantees of WinRT to be circumvented.

    0 讨论(0)
  • 2021-01-02 04:36

    To make it more interesting, IE 10 does in fact do JIT on its js code, so the API is clearly there to allow it.

    0 讨论(0)
  • 2021-01-02 04:37

    You can create a Windows Runtime Component (Universal Windows) C++, You access the Component from c# code, inside the component you can call LoadPackagedLibrary, which has the restriction that it can only load DLL's that are packaged with your app. Otherwise it is same as LoadLibrary.

    You cannot download and dynamically load, as ApplicationData and InstalledLocation are different locations. (LoadPackagedLibrary doesn not allow you to specify path). And you can only write to ApplicationData...

    0 讨论(0)
  • 2021-01-02 04:38

    Ya its possible , Check the Google Chrome app in Windows 8 , They are providing a way to switch between normal mode & windows 8 mode persisting the pages viewed.

    0 讨论(0)
  • 2021-01-02 04:42

    Windows 10 adds the codeGeneration capability for this purpose. This allows the functions VirtualAllocFromApp and VirtualProtectFromApp to be used in WinRT apps as VirtualAlloc and VirtualProtect would be used in Win32.

    0 讨论(0)
提交回复
热议问题