Skip to content

Commit

Permalink
m: Format DNS_QUERY_RESULT correctly
Browse files Browse the repository at this point in the history
Signed-off-by: John Nunley <[email protected]>
  • Loading branch information
notgull committed Jun 12, 2024
1 parent 27b44a7 commit 080b75c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions async-dns/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,31 @@ where

// Create the initial request.
let request = dns::DNS_QUERY_REQUEST {
Version: 1,
Version: dns::DNS_QUERY_REQUEST_VERSION1,
QueryName: name.as_ptr(),
QueryType: query_type,
QueryOptions: 0,
pQueryCompletionCallback: Some(dns_completion_callback::<F>),
pQueryContext: Box::into_raw(complete) as *mut c_void,
..unsafe { mem::zeroed() }
InterfaceIndex: 0,
pDnsServerList: std::ptr::null_mut()
};

// Create space for the results.
let mut immediate_results = mem::MaybeUninit::<dns::DNS_QUERY_RESULT>::zeroed();
let mut cancel_handle = mem::MaybeUninit::<dns::DNS_QUERY_CANCEL>::zeroed();
let mut immediate_results = dns::DNS_QUERY_RESULT {
Version: dns::DNS_QUERY_REQUEST_VERSION1,
..unsafe { mem::zeroed() }
};
let mut cancel_handle = mem::MaybeUninit::<dns::DNS_QUERY_CANCEL>::uninit();

// The first field of immediate_results must be version 1.


// Call the function proper.
let res = unsafe {
dns::DnsQueryEx(
&request,
immediate_results.as_mut_ptr(),
&mut immediate_results,
cancel_handle.as_mut_ptr(),
)
};
Expand All @@ -195,7 +202,7 @@ where
// The query was successful and it completed immediately.
// Get the closure back and run it.
let closure = unsafe { Box::from_raw(request.pQueryContext as *mut F) };
(closure)(immediate_results.as_mut_ptr());
(closure)(&mut immediate_results);
Ok(None)
}
found::DNS_REQUEST_PENDING => {
Expand Down

0 comments on commit 080b75c

Please sign in to comment.