Skip to content

Commit 44ec3d7

Browse files
wan9chicodex
andcommitted
refactor(fspy): parse attribute pointer references
Co-authored-by: GPT-5.6 <codex@openai.com>
1 parent 39bd6e6 commit 44ec3d7

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

  • crates/fspy_preload_windows/src/windows/detours

crates/fspy_preload_windows/src/windows/detours/nt.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,12 @@ unsafe fn read_process_image_attribute<'a>(
130130
let attribute_count =
131131
(attribute_list.TotalLength - attributes_offset) / size_of::<PS_ATTRIBUTE>();
132132

133-
// SAFETY: TotalLength covers a contiguous variable-length tail by API contract; addr_of avoids
134-
// first creating a reference to the one-element placeholder array in the Rust definition.
135-
let attributes: &[PS_ATTRIBUTE] = unsafe {
136-
std::slice::from_raw_parts(
137-
std::ptr::addr_of!(attribute_list.Attributes).cast(),
138-
attribute_count,
139-
)
140-
};
133+
// The Rust field exposes the first placeholder entry as a reference; TotalLength describes how
134+
// many contiguous entries follow it in the actual variable-length allocation.
135+
let first_attribute = attribute_list.Attributes.first()?;
136+
// SAFETY: TotalLength covers a contiguous variable-length tail starting at first_attribute.
137+
let attributes: &[PS_ATTRIBUTE] =
138+
unsafe { std::slice::from_raw_parts(std::ptr::from_ref(first_attribute), attribute_count) };
141139
for attribute in attributes {
142140
if attribute.Attribute != PS_ATTRIBUTE_IMAGE_NAME {
143141
continue;

0 commit comments

Comments
 (0)