MCPcopy Create free account
hub / github.com/M2Team/NanaBox / SponsorButtonClick

Method SponsorButtonClick

NanaBox/MainWindowControl.cpp:256–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254 }
255
256 void MainWindowControl::SponsorButtonClick(
257 winrt::IInspectable const& sender,
258 winrt::RoutedEventArgs const& e)
259 {
260 UNREFERENCED_PARAMETER(sender);
261 UNREFERENCED_PARAMETER(e);
262
263 winrt::handle(Mile::CreateThread([=]()
264 {
265 DWORD ShellProcessId = ::GetShellProcessId();
266 if (static_cast<DWORD>(-1) == ShellProcessId)
267 {
268 return;
269 }
270
271 HANDLE ShellProcessHandle = nullptr;
272
273 auto Handler = Mile::ScopeExitTaskHandler([&]()
274 {
275 if (ShellProcessHandle)
276 {
277 ::CloseHandle(ShellProcessHandle);
278 }
279 });
280
281 ShellProcessHandle = ::OpenProcess(
282 PROCESS_CREATE_PROCESS,
283 FALSE,
284 ShellProcessId);
285 if (!ShellProcessHandle)
286 {
287 return;
288 }
289
290 SIZE_T AttributeListSize = 0;
291 ::InitializeProcThreadAttributeList(
292 nullptr,
293 1,
294 0,
295 &AttributeListSize);
296
297 std::vector<std::uint8_t> AttributeListBuffer =
298 std::vector<std::uint8_t>(AttributeListSize);
299
300 PPROC_THREAD_ATTRIBUTE_LIST AttributeList =
301 reinterpret_cast<PPROC_THREAD_ATTRIBUTE_LIST>(
302 &AttributeListBuffer[0]);
303
304 if (!::InitializeProcThreadAttributeList(
305 AttributeList,
306 1,
307 0,
308 &AttributeListSize))
309 {
310 return;
311 }
312
313 if (!::UpdateProcThreadAttribute(

Callers

nothing calls this directly

Calls 3

GetShellProcessIdFunction · 0.85

Tested by

no test coverage detected