MCPcopy Index your code
hub / github.com/RustPython/RustPython / query_thread_impl

Function query_thread_impl

crates/vm/src/stdlib/_wmi.rs:313–556  ·  view source on GitHub ↗
(param: *mut c_void)

Source from the content-addressed store, hash-verified

311 }
312
313 unsafe fn query_thread_impl(param: *mut c_void) -> u32 {
314 unsafe {
315 let data = Box::from_raw(param as *mut QueryThreadData);
316 let write_pipe = data.write_pipe;
317 let init_event = data.init_event;
318 let connect_event = data.connect_event;
319
320 let mut locator: *mut c_void = null_mut();
321 let mut services: *mut c_void = null_mut();
322 let mut enumerator: *mut c_void = null_mut();
323 let mut hr: HRESULT = 0;
324
325 // gh-125315: Copy the query string first
326 let bstr_query = SysAllocString(data.query.as_ptr());
327 if bstr_query.is_null() {
328 hr = hresult_from_win32(ERROR_NOT_ENOUGH_MEMORY);
329 }
330
331 drop(data);
332
333 if succeeded(hr) {
334 hr = CoInitializeEx(null_mut(), COINIT_APARTMENTTHREADED);
335 }
336
337 if failed(hr) {
338 CloseHandle(write_pipe);
339 if !bstr_query.is_null() {
340 SysFreeString(bstr_query);
341 }
342 return hr as u32;
343 }
344
345 hr = CoInitializeSecurity(
346 null(),
347 -1,
348 null(),
349 null(),
350 RPC_C_AUTHN_LEVEL_DEFAULT,
351 RPC_C_IMP_LEVEL_IMPERSONATE,
352 null(),
353 EOAC_NONE,
354 null(),
355 );
356 // gh-96684: CoInitializeSecurity will fail if another part of the app has
357 // already called it.
358 if hr == RPC_E_TOO_LATE {
359 hr = 0;
360 }
361
362 if succeeded(hr) {
363 hr = CoCreateInstance(
364 &CLSID_WBEM_LOCATOR,
365 null_mut(),
366 CLSCTX_INPROC_SERVER,
367 &IID_IWBEM_LOCATOR,
368 &mut locator,
369 );
370 }

Callers 1

query_threadFunction · 0.85

Calls 15

hresult_from_win32Function · 0.85
succeededFunction · 0.85
failedFunction · 0.85
CloseHandleFunction · 0.85
wide_strFunction · 0.85
locator_connect_serverFunction · 0.85
services_exec_queryFunction · 0.85
enum_nextFunction · 0.85
WriteFileFunction · 0.85
com_releaseFunction · 0.85
object_begin_enumerationFunction · 0.85
object_nextFunction · 0.85

Tested by

no test coverage detected