C++/WinRT
Перейти к файлу
Ryan Shepherd f65801e69f
Zero-fill padding in detach_abi(com_array) (#1165)
A code analysis warning recently fired for a customer on detach_abi(com_array<T>). This function returns a std::pair<uint32_t, some_pointer_type>, which will have, on 64-bit builds, 4 bytes of padding between the uint32 size and the pointer members. Currently, that padding is uninitialized.

The idea behind the code analysis warning is that information may be leaked via those unitialized bytes.

In practice, that's almost never going to be an issue for this function, because the std::pair is not an interesting object to pass around, and only exists as a convenience to return both the size and buffer of the com_array at the same time.

However, the fix removes a pain point for a customer, is simple, risk-free, and actually gets optimized away in the 99% use case (return value stored in a local variable, access only the first/second members, not the padding bytes).  Demo showing optimization: https://godbolt.org/z/T4vPhMKxn
2022-07-06 14:05:20 -07:00
cppwinrt Static events should not use the auto trick (#1158) 2022-06-08 15:05:47 -07:00
fast_fwd Several nuget tests failing to build with VS2022. Standardize on directory.build.props to use PlatformToolset v143 (#1125) 2022-03-22 15:14:59 -07:00
natvis per request, provide implementation-side visualizations. and always show raw data. (#1128) 2022-03-24 10:06:41 -07:00
nuget Clarify usage of ComponentConnectorT::InitializeComponent (#1161) 2022-07-05 08:23:01 -07:00
prebuild catch is evidently incompatible with VS 2022 (platform toolset v143) - backing off to unblock (#1127) 2022-03-23 15:35:56 -07:00
scratch catch is evidently incompatible with VS 2022 (platform toolset v143) - backing off to unblock (#1127) 2022-03-23 15:35:56 -07:00
strings Zero-fill padding in detach_abi(com_array) (#1165) 2022-07-06 14:05:20 -07:00
test Static events should not use the auto trick (#1158) 2022-06-08 15:05:47 -07:00
vsix two-phase initialization support to prevent double-destruction on handing out this pointer in ctor (#1130) 2022-03-31 10:16:00 -07:00
.gitattributes Build (#478) 2020-01-16 09:16:13 -08:00
.gitignore Generate test failure output on abnormal termination (#1011) 2021-09-07 17:09:41 -07:00
CODE_OF_CONDUCT.md clean 2019-10-08 05:14:30 -07:00
Directory.Build.Props catch is evidently incompatible with VS 2022 (platform toolset v143) - backing off to unblock (#1127) 2022-03-23 15:35:56 -07:00
Directory.Build.Targets catch is evidently incompatible with VS 2022 (platform toolset v143) - backing off to unblock (#1127) 2022-03-23 15:35:56 -07:00
LICENSE clean 2019-10-08 05:14:30 -07:00
README.md Update README.md 2021-01-02 08:51:52 -08:00
SECURITY.md clean 2019-10-08 05:14:30 -07:00
build_nuget.cmd Fix build 2020-07-03 18:34:57 -07:00
build_projection.cmd build 2019-10-11 09:06:48 -07:00
build_test_all.cmd catch is evidently incompatible with VS 2022 (platform toolset v143) - backing off to unblock (#1127) 2022-03-23 15:35:56 -07:00
build_vsix.cmd Lay groundwork for localizing VSIX templates and remove Dev15 build cruft (#1060) 2021-12-02 12:04:55 -08:00
compile_tests.cmd port 2019-10-08 08:19:10 -07:00
cppwinrt.sln Simplify use of `WINRT_NO_MODULE_LOCK` in DLLs (#1032) 2021-09-30 16:16:21 -07:00
run_tests.cmd Generate test failure output on abnormal termination (#1011) 2021-09-07 17:09:41 -07:00

README.md

Build status

The C++/WinRT language projection

C++/WinRT is an entirely standard C++ language projection for Windows Runtime (WinRT) APIs, implemented as a header-file-based library, and designed to provide you with first-class access to the modern Windows API. With C++/WinRT, you can author and consume Windows Runtime APIs using any standards-compliant C++17 compiler.

Building C++/WinRT

Don't build C++/WinRT yourself - just download the latest version here: https://aka.ms/cppwinrt/nuget

If you really want to build it yourself, the simplest way to do so is to run the build_test_all.cmd script in the root directory. Developers needing to work on the C++/WinRT compiler itself should go through the following steps to arrive at an efficient inner loop:

  • Open a dev command prompt pointing at the root of the repo.
  • Open the cppwinrt.sln solution.
  • Build the x64 Release configuration of the prebuild and cppwinrt projects only. Do not attempt to build anything else just yet.
  • Run build_projection.cmd in the dev command prompt.
  • Switch to the x64 Debug configuration in Visual Studio and build all projects as needed.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.