diff --git a/Directory.Build.props b/Directory.Build.props
index 218fa80..c1d3a9f 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -36,9 +36,9 @@
true
true
- <_CertificateThumbprint>$(CertificateThumbprint)
+ <_CertificateThumbprint Condition="'$(_CertificateThumbprint)' != ''">$(CertificateThumbprint)
<_CertificateThumbprint Condition="'$(_CertificateThumbprint)' == ''">b834c6c1d7e0ae8e76cadcf9e2e7a273133a5df6
- <_TimestampUrl>$(TimestampUrl)
+ <_TimestampUrl Condition="'$(_TimestampUrl)' != ''"> $(TimestampUrl)
<_TimestampUrl Condition="'$(_TimestampUrl)' == ''">http://time.certum.pl/
@@ -114,11 +114,15 @@
* WINRT *
WINRT_LEAN_AND_MEAN: Disables rarely-used features (in order to reduce compile times)
+ WINRT_NO_SOURCE_LOCATION (prevents full namespace names in the binary).
* Secure C Runtime *
__STDC_WANT_SECURE_LIB__=1;
+
+ * Microsoft STL *
+ _USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION=0: Keep function name info short to reduce binary size.
-->
- WIN32_LEAN_AND_MEAN;NOSERVICE;NOMCX;NOIME;NOMINMAX;WINRT_LEAN_AND_MEAN;__STDC_WANT_SECURE_LIB__=1;%(PreprocessorDefinitions)
+ WIN32_LEAN_AND_MEAN;NOSERVICE;NOMCX;NOIME;NOMINMAX;WINRT_LEAN_AND_MEAN;WINRT_NO_SOURCE_LOCATION;__STDC_WANT_SECURE_LIB__=1;_USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION=0;%(PreprocessorDefinitions)
NotUsing
@@ -133,6 +137,7 @@
true
true
10
+ false
true
@@ -148,11 +153,19 @@
+
+ true
+ true
+
+
+ false
+ false
true
true
true
false
+ true
@@ -160,6 +173,20 @@
true
true
+ %(AdditionalOptions) /Brepro
+ false
+ false
+ true
+ true
+ NDEBUG;%(PreprocessorDefinitions)
+
+ true
+ true
+
+
+ /PDBALTPATH:%_PDB% /Brepro %(AdditionalOptions)
+
+
diff --git a/src/class_factory.ixx b/src/class_factory.ixx
index 48c2a5a..1f86625 100644
--- a/src/class_factory.ixx
+++ b/src/class_factory.ixx
@@ -22,7 +22,7 @@ struct class_factory : winrt::implements, IClassFactory>
}
catch (...)
{
- return winrt::to_hresult();
+ return to_hresult();
}
HRESULT __stdcall LockServer(BOOL) noexcept override
diff --git a/src/dll_main.cpp b/src/dll_main.cpp
index 7ef0d4c..895f5b9 100644
--- a/src/dll_main.cpp
+++ b/src/dll_main.cpp
@@ -16,7 +16,6 @@ import util;
import property_store;
using std::array;
-using std::format;
using std::uint32_t;
using std::wstring;
using namespace std::string_literals;
@@ -78,11 +77,11 @@ void register_decoder_file_extension(const wchar_t* file_type_name, const wchar_
constexpr wchar_t class_id_thumbnail_provider[]{L"{e357fccd-a995-4576-b01f-234630154e96}"};
constexpr wchar_t class_id_photo_thumbnail_provider[]{L"{c7657c4a-9f68-40fa-a4df-96bc08eb3551}"};
- registry::set_value(format(LR"(SOFTWARE\Classes\{}\ShellEx\{})", file_type_name, class_id_thumbnail_provider), L"",
+ registry::set_value(LR"(SOFTWARE\Classes\)"s + file_type_name + LR"(\ShellEx\)" + class_id_thumbnail_provider, L"",
class_id_photo_thumbnail_provider);
- registry::set_value(
- format(LR"(SOFTWARE\Classes\SystemFileAssociations\{}\ShellEx\{})", file_extension, class_id_thumbnail_provider),
- L"", class_id_photo_thumbnail_provider);
+ registry::set_value(LR"(SOFTWARE\Classes\SystemFileAssociations\)"s + file_extension + LR"()\ShellEx\)" +
+ class_id_thumbnail_provider,
+ L"", class_id_photo_thumbnail_provider);
// Register with the legacy Windows Photo Viewer (still installed on Windows 11 and 10): just forward to the TIFF
// registration.
@@ -93,7 +92,7 @@ void register_decoder_file_extension(const wchar_t* file_type_name, const wchar_
void register_decoder_pattern(const wstring& sub_key, const int index, const std::span pattern)
{
const wstring patterns_sub_key{sub_key + LR"(\Patterns\)" + std::to_wstring(index)};
- constexpr array mask{0xFF_byte, 0xFF_byte};
+ constexpr array mask{std::byte{0xFF}, std::byte{0xFF}};
registry::set_value(patterns_sub_key, L"Length", static_cast(pattern.size()));
registry::set_value(patterns_sub_key, L"Position", 0U);
registry::set_value(patterns_sub_key, L"Mask", mask);
@@ -122,8 +121,7 @@ void register_property_store_file_extension(const wchar_t* file_extension)
L"", guid_to_string(id::property_store_class).c_str());
const auto sub_key = LR"(SOFTWARE\Classes\SystemFileAssociations\)"s + file_extension;
- registry::set_value(sub_key, L"ExtendedTileInfo",
- L"prop:System.ItemType;*System.DateModified;*System.Image.Dimensions");
+ registry::set_value(sub_key, L"ExtendedTileInfo", L"prop:System.ItemType;*System.DateModified;*System.Image.Dimensions");
registry::set_value(
sub_key, L"FullDetails",
L"prop:System.PropGroup.Image;System.Image.Dimensions;System.Image.HorizontalSize;System.Image.VerticalSize;System."
@@ -213,13 +211,13 @@ try
}
catch (...)
{
- return winrt::to_hresult();
+ return to_hresult();
}
// Purpose: Used to determine whether the COM sub-system can unload the DLL from memory.
extern "C" __control_entrypoint(DllExport) HRESULT __stdcall DllCanUnloadNow()
{
- const auto result{winrt::get_module_lock() ? S_FALSE : S_OK};
+ const auto result{winrt::get_module_lock() ? success_false : success_ok};
TRACE("netpbm-wic-codec::DllCanUnloadNow hr = {} (0 = S_OK -> unload OK)\n", result);
return result;
}
@@ -237,7 +235,7 @@ try
}
catch (...)
{
- TRACE("netpbm-wic-codec::DllRegisterServer failed hr = {}\n", winrt::to_hresult());
+ TRACE("netpbm-wic-codec::DllRegisterServer failed hr = {}\n", to_hresult());
return self_registration::error_class;
}
@@ -250,7 +248,7 @@ try
}
catch (...)
{
- const HRESULT hresult{winrt::to_hresult()};
+ const HRESULT hresult{to_hresult()};
TRACE("netpbm-wic-codec::DllUnregisterServer failed hr = {}\n", hresult);
return hresult;
}
diff --git a/src/hresults.ixx b/src/hresults.ixx
index 8ce432c..2e671b7 100644
--- a/src/hresults.ixx
+++ b/src/hresults.ixx
@@ -20,6 +20,7 @@ constexpr HRESULT error_no_aggregation{CLASS_E_NOAGGREGATION};
constexpr HRESULT error_class_not_available{CLASS_E_CLASSNOTAVAILABLE};
constexpr HRESULT error_invalid_argument{E_INVALIDARG};
constexpr HRESULT error_access_denied{STG_E_ACCESSDENIED};
+constexpr HRESULT error_out_of_memory{E_OUTOFMEMORY};
namespace self_registration {
diff --git a/src/netpbm-wic-codec.vcxproj b/src/netpbm-wic-codec.vcxproj
index ecd20d9..a815575 100644
--- a/src/netpbm-wic-codec.vcxproj
+++ b/src/netpbm-wic-codec.vcxproj
@@ -1,5 +1,8 @@
+
+
+
@@ -28,7 +31,7 @@
- 16.0
+ 17.0
Win32Proj
{c50cd24b-6a16-4a25-98e8-3d958449c411}
netpbmwiccodec
@@ -37,150 +40,11 @@
$(DefaultPlatformToolset)
-
-
- DynamicLibrary
- true
-
-
- DynamicLibrary
- false
- true
-
-
- DynamicLibrary
- true
-
-
- DynamicLibrary
- true
-
-
DynamicLibrary
- false
- true
-
-
- DynamicLibrary
- false
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- false
-
-
- true
-
-
- true
-
-
- false
-
-
- false
-
-
-
-
-
-
-
- Windows
- true
- false
- netpbm-wic-codec.def
-
-
-
-
- true
- true
- NDEBUG;%(PreprocessorDefinitions)
-
-
- Windows
- true
- true
- true
- false
- netpbm-wic-codec.def
-
-
-
-
- /FS %(AdditionalOptions)
-
-
- Windows
- true
- false
- netpbm-wic-codec.def
-
-
-
-
- Windows
- true
- false
- netpbm-wic-codec.def
-
-
-
-
- true
- true
- NDEBUG;%(PreprocessorDefinitions)
- /FS %(AdditionalOptions)
-
-
- Windows
- true
- true
- true
- false
- netpbm-wic-codec.def
-
-
-
-
- true
- true
- NDEBUG;%(PreprocessorDefinitions)
-
+
- Windows
- true
- true
- true
- false
netpbm-wic-codec.def
@@ -223,6 +87,9 @@
+
+
+
@@ -230,6 +97,12 @@
+
+
+
+
+
+
diff --git a/src/netpbm_bitmap_decoder.cpp b/src/netpbm_bitmap_decoder.cpp
index 41891e6..5a5f261 100644
--- a/src/netpbm_bitmap_decoder.cpp
+++ b/src/netpbm_bitmap_decoder.cpp
@@ -22,7 +22,6 @@ using std::scoped_lock;
using std::uint32_t;
using winrt::check_hresult;
using winrt::com_ptr;
-using winrt::to_hresult;
namespace {
diff --git a/src/netpbm_bitmap_frame_decode.cpp b/src/netpbm_bitmap_frame_decode.cpp
index 379800f..8d02f4f 100644
--- a/src/netpbm_bitmap_frame_decode.cpp
+++ b/src/netpbm_bitmap_frame_decode.cpp
@@ -25,8 +25,6 @@ using std::ranges::transform;
using winrt::check_hresult;
using winrt::com_ptr;
using winrt::throw_hresult;
-using winrt::to_hresult;
-
namespace {
diff --git a/src/packages.config b/src/packages.config
index 7a9561b..9ecc038 100644
--- a/src/packages.config
+++ b/src/packages.config
@@ -1,4 +1,7 @@
+
+
+
\ No newline at end of file
diff --git a/src/property_store.cpp b/src/property_store.cpp
index 87ddc47..9420cc5 100644
--- a/src/property_store.cpp
+++ b/src/property_store.cpp
@@ -23,7 +23,6 @@ using std::span;
using std::pair;
using std::uint32_t;
using winrt::check_hresult;
-using winrt::to_hresult;
namespace {
@@ -81,7 +80,7 @@ struct property_store : winrt::implements(IMAGE_COMPRESSION_UNCOMPRESSED)};
initialized_ = true;
@@ -97,7 +96,7 @@ struct property_store : winrt::implements(length * sizeof(wchar_t)))); // NOLINT(bugprone-misplaced-widening-cast)
}
-export void set_value(const std::wstring& sub_key, _Null_terminated_ const wchar_t* value_name,
+export inline void set_value(const std::wstring& sub_key, _Null_terminated_ const wchar_t* value_name,
_Null_terminated_ const wchar_t* value)
{
set_value(sub_key.c_str(), value_name, value);
diff --git a/src/util.ixx b/src/util.ixx
index 1813634..c4c6e09 100644
--- a/src/util.ixx
+++ b/src/util.ixx
@@ -26,35 +26,6 @@ namespace {
} // namespace
-export constexpr std::byte operator"" _byte(const unsigned long long int n)
-{
- return static_cast(n);
-}
-
-
-export [[nodiscard]] const char* pixel_format_to_string(const GUID& guid) noexcept
-{
- if (guid == GUID_WICPixelFormat2bppGray)
- return "GUID_WICPixelFormat2bppGray";
-
- if (guid == GUID_WICPixelFormat4bppGray)
- return "GUID_WICPixelFormat4bppGray";
-
- if (guid == GUID_WICPixelFormat8bppGray)
- return "GUID_WICPixelFormat8bppGray";
-
- if (guid == GUID_WICPixelFormat16bppGray)
- return "GUID_WICPixelFormat16bppGray";
-
- if (guid == GUID_WICPixelFormat24bppRGB)
- return "GUID_WICPixelFormat24bppRGB";
-
- if (guid == GUID_WICPixelFormat48bppRGB)
- return "GUID_WICPixelFormat48bppRGB";
-
- return "Unknown";
-}
-
export [[nodiscard]] std::wstring guid_to_string(const GUID& guid)
{
std::wstring guid_text;
@@ -89,19 +60,9 @@ export [[nodiscard]] std::wstring get_module_path()
return path;
}
-export template<>
-struct std::formatter : std::formatter
-{
- auto format(const winrt::hresult& result, std::format_context& ctx) const
- {
- return std::formatter::format(result.value, ctx);
- }
-};
-
// Copied from fmtlib as standard C++20 lacks this helper method and requires fmt_ptr
export template
-[[nodiscard]]
-auto fmt_ptr(T p) noexcept -> const void*
+[[nodiscard]] auto fmt_ptr(T p) noexcept -> const void*
{
static_assert(std::is_pointer_v);
return std::bit_cast(p);
@@ -141,3 +102,19 @@ export void check_condition(const bool condition, const winrt::hresult result_to
if (!condition)
throw_hresult(result_to_throw);
}
+
+export __declspec(noinline) HRESULT to_hresult() noexcept
+{
+ try
+ {
+ throw;
+ }
+ catch (winrt::hresult_error const& e)
+ {
+ return e.code();
+ }
+ catch (std::bad_alloc const&)
+ {
+ return error_out_of_memory;
+ }
+}
diff --git a/src/winrt.ixx b/src/winrt.ixx
index a7abbeb..4e5c539 100644
--- a/src/winrt.ixx
+++ b/src/winrt.ixx
@@ -30,6 +30,6 @@ using winrt::implements;
using winrt::make;
using winrt::make_self;
using winrt::throw_hresult;
-using winrt::to_hresult;
+using winrt::hresult_error;
} // namespace winrt
diff --git a/std-header-units/std-header-units.vcxproj b/std-header-units/std-header-units.vcxproj
index 6a4acac..95db6fa 100644
--- a/std-header-units/std-header-units.vcxproj
+++ b/std-header-units/std-header-units.vcxproj
@@ -27,7 +27,7 @@
- 16.0
+ 17.0
Win32Proj
{db8d6fc8-6f7b-446f-892a-0ba6c779e5f2}
stdheaderunits
@@ -37,131 +37,11 @@
$(DefaultPlatformToolset)
StaticLibrary
-
- true
-
-
- false
- true
-
-
- true
-
-
- true
-
-
- false
- true
-
-
- false
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- false
-
-
- true
-
-
- true
-
-
- false
-
-
- false
-
-
-
- true
-
-
- true
-
-
-
-
- true
- true
- NDEBUG;%(PreprocessorDefinitions)
- true
-
-
- true
- true
- true
-
-
-
-
- true
-
-
- true
-
-
-
-
- true
-
-
- true
-
-
-
-
- true
- true
- NDEBUG;%(PreprocessorDefinitions)
- true
-
-
- true
- true
- true
-
-
-
+
- true
- true
- NDEBUG;%(PreprocessorDefinitions)
true
-
- true
- true
- true
-
@@ -170,5 +50,4 @@
-
\ No newline at end of file
diff --git a/test/test.vcxproj b/test/test.vcxproj
index 52a2202..1401e84 100644
--- a/test/test.vcxproj
+++ b/test/test.vcxproj
@@ -28,7 +28,7 @@
- 16.0
+ 17.0
{F2EA965E-98D3-41C6-90D1-3DE4837D1041}
Win32Proj
unittest
@@ -38,129 +38,13 @@
$(DefaultPlatformToolset)
-
-
- true
-
-
- false
- true
+ false
- Windows
$(IntDir)../netpbm-wic-codec/
- pnm_header.ixx.obj;hresults.ixx.obj;buffered_stream_reader.obj;%(AdditionalDependencies)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- true
-
-
- true
-
-
- false
- false
-
-
- false
- false
-
-
- false
- false
-
-
-
- Onecore.lib;windowscodecs.lib;Shlwapi.lib;%(AdditionalDependencies)
-
-
-
-
- true
- $(IntDir)../netpbm-wic-codec/pnm_header.ixx.ifc
- $(IntDir)../netpbm-wic-codec/
- ProgramDatabase
-
-
-
-
- true
- $(IntDir)../netpbm-wic-codec/pnm_header.ixx.ifc
- $(IntDir)../netpbm-wic-codec/
-
-
-
-
- true
- $(IntDir)../netpbm-wic-codec/pnm_header.ixx.ifc
-
-
-
-
- true
- true
- NDEBUG;%(PreprocessorDefinitions)
- true
- $(IntDir)../netpbm-wic-codec/pnm_header.ixx.ifc
-
-
- true
- true
-
-
-
-
- true
- true
- NDEBUG;%(PreprocessorDefinitions)
- true
- $(IntDir)../netpbm-wic-codec/pnm_header.ixx.ifc
-
-
- true
- true
-
-
-
-
- true
- true
- NDEBUG;%(PreprocessorDefinitions)
- true
- $(IntDir)../netpbm-wic-codec/pnm_header.ixx.ifc
-
-
- true
- true
+ windowscodecs.lib;Shlwapi.lib;pnm_header.ixx.obj;buffered_stream_reader.obj;%(AdditionalDependencies)
@@ -240,6 +124,7 @@
{db8d6fc8-6f7b-446f-892a-0ba6c779e5f2}
+ false