Skip to content

Bug: IMAGE_ORDINAL_FLAG should be pointer-sized, not always equal to IMAGE_ORDINAL_FLAG64 #1003

@rsta79

Description

@rsta79

Which crate is this about?

windows-sys

Crate version

0.36.1

Summary

As the title, IMAGE_ORDINAL_FLAG should be pointer-sized like usize, but IMAGE_ORDINAL_FLAG is not pointer-sized in windows-sys 0.36.1 , IMAGE_ORDINAL_FLAG should define with attribute #[cfg(target-pointer-width = "<32/64>")] or something like that.

Toolchain version/configuration

installed toolchains

stable-x86_64-pc-windows-msvc (default)
nightly-x86_64-pc-windows-msvc
1.59-x86_64-pc-windows-msvc

installed targets for active toolchain

i686-pc-windows-msvc
wasm32-unknown-unknown
wasm32-wasi
x86_64-pc-windows-msvc

active toolchain

Reproducible example

use windows_sys::Win32::System::SystemServices::IMAGE_ORDINAL_FLAG;
use std::mem::size_of;
use std::any::type_name;

fn type_of<T>(_: T) -> &'static str {
	return type_name::<T>()
}
fn main() {
    println!("Size of usize in memory: {size}", size = size_of::<usize>());
    println!("IMAGE_ORDINAL_FLAG: {value}({type})", value = IMAGE_ORDINAL_FLAG, type = type_of(IMAGE_ORDINAL_FLAG));
}

Crate manifest

[package]
name = "windows_ordinal_flag_test"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
windows-sys = {version = "0.36.1", features = ["Win32_System_SystemServices"]}

Expected behavior

cargo run --target i686-pc-windows-msvc / 32bit target

Size of usize in memory: 4
IMAGE_ORDINAL_FLAG: 2147483648(u32)

cargo run (--target stable-x86_64-pc-windows-msvc) / 64bit target

Size of usize in memory: 8
IMAGE_ORDINAL_FLAG: 9223372036854775808(u64)

Actual behavior

cargo run --target i686-pc-windows-msvc / 32bit target

Size of usize in memory: 4
IMAGE_ORDINAL_FLAG: 9223372036854775808(u64)

cargo run (--target stable-x86_64-pc-windows-msvc) / 64bit target

Size of usize in memory: 8
IMAGE_ORDINAL_FLAG: 9223372036854775808(u64)

Additional comments

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions