MCPcopy Create free account
hub / github.com/DFIR-ORC/dfir-orc / UpdateFileResource

Function UpdateFileResource

tools/rcedit/src/cmd/set/cmd_set.cpp:55–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53namespace {
54
55void UpdateFileResource(
56 const fs::path& path,
57 const std::wstring& type,
58 const std::wstring& name,
59 const std::optional< std::wstring >& lang,
60 const std::vector< uint8_t >& value,
61 std::error_code& ec )
62{
63 BOOL ret = FALSE;
64
65 guard::BeginUpdateResourceHandleW hUpdate =
66 BeginUpdateResourceW( path.c_str(), FALSE );
67
68 if( !hUpdate ) {
69 ec.assign( GetLastError(), std::system_category() );
70 spdlog::debug( "Failed BeginUpdateResource: {}", ec.message() );
71 return;
72 }
73
74 const auto langId =
75 lang ? std::stoi( *lang ) : MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL );
76
77 ret = UpdateResourceW(
78 hUpdate.get(),
79 type.c_str(),
80 name.c_str(),
81 langId,
82 reinterpret_cast< LPVOID >( const_cast< uint8_t* >( value.data() ) ),
83 static_cast< DWORD >( value.size() ) );
84
85 if( ret == FALSE ) {
86 ec.assign( GetLastError(), std::system_category() );
87 spdlog::debug( "Failed UpdateResource: {}", ec.message() );
88 return;
89 }
90
91 ret = EndUpdateResourceW( hUpdate.get(), FALSE );
92
93 if( ret == FALSE ) {
94 ec.assign( GetLastError(), std::system_category() );
95 spdlog::debug( "Failed EndUpdateResource: {}", ec.message() );
96 return;
97 }
98
99 hUpdate.detach();
100}
101
102std::pair< std::string_view, guard::MapView > MapFile(
103 const fs::path filePath,

Callers 1

ExecuteMethod · 0.85

Calls 7

c_strMethod · 0.80
messageMethod · 0.80
detachMethod · 0.80
assignMethod · 0.45
getMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected