MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / Execute

Method Execute

WinArk/ChangeValueCommand.cpp:13–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13bool ChangeValueCommand::Execute() {
14 auto key = Registry::OpenKey(GetPath(), KEY_SET_VALUE | KEY_QUERY_VALUE);
15 if (!key)
16 return false;
17
18 // read old value
19 ULONG size = 0;
20 DWORD type;
21 key.QueryValue(GetName(), &type, nullptr, &size);
22 auto buffer = std::make_unique<BYTE[]>(size);
23 auto error = key.QueryValue(GetName(), &type, buffer.get(), &size);
24 if (ERROR_SUCCESS != error) {
25 ::SetLastError(error);
26 return false;
27 }
28
29 //
30 // make the change
31 //
32 error = key.SetValue(GetName(), _type, _data.get(), _size);
33 if (ERROR_SUCCESS != error) {
34 ::SetLastError(error);
35 return false;
36 }
37
38 _size = size;
39 _type = type;
40 _data = std::move(buffer);
41
42 return InvokeCallback(false);
43}

Callers

nothing calls this directly

Calls 2

QueryValueMethod · 0.80
SetValueMethod · 0.45

Tested by

no test coverage detected