Comments (7)
FILETIME
and ULARGE_INTEGER
are not interchangeable because they have different alignment. FILETIME
consists of two 32-bit fields whereas ULARGE_INTEGER
consists of a union, one of whose fields is a single 64-bit value. Hence the alignment of ULARGE_INTEGER
will be 8 bytes and the alignment of FILETIME
will be 4 bytes.
So it is indeed safe to replace ULARGE_INTEGER
and LARGE_INTEGER
with uint64
and int64
but it is not safe to do so for FILETIME
.
from cswin32.
Yes, for C# it would be the CsWin32 repo.
from cswin32.
@saul - I've just transferred it here for you.
from cswin32.
There are other types like FILETIME
with the same layout as ULARGE_INTEGER
, where Microsoft recommends not to replace the structure with a 64 bit integer because of alignment issues. I neither am sure if this also applies for LARGE_INTEGER
and ULARGE_INTEGER
, nor if this even affects modern CPUs that Windows runs on.
from cswin32.
I believe that doing this would break ABI, based on my experiences with microsoft/cppwin32#3.
The gist of what I found in that defect is that this:
int64 f1();
and this:
struct S
{
int 64 value;
}
S f2();
are going to push different amounts of stuff onto the stack, causing memory corruption and crashes if we try to pretend one of them is the other.
We need to keep these structs as-is in the metadata. Projections are free to simplify them and project them idiomatically, but the structs need to exist in metadata so that we preserve ABI compatibility.
from cswin32.
Right, there is a peculiarity in the C++ ABI for the Visual C++ compiler that results in these being different when stdcall
is involved. Rust for Windows already maps these to i64 and u64 because it doesn't suffer from this weirdness, but Visual C++ may not be able to handle that reliably.
If your language doesn't yet map this in a natural way, I suggest you open an issue with the language team.
from cswin32.
Okay just so we're on the same page - should I open an issue on CsWin32 to have the struct projected to int64/uint64?
from cswin32.
Related Issues (20)
- `FindFirstFileExFromApp` generate `void*` at `lpFindFileData` HOT 1
- How to create instance for `IDesktopWallpaper` COM interface HOT 3
- Add EntryPoint #865 IsElevationRequired HOT 1
- CS8785 when adding a locally built copy of Windows.Win32.winmd HOT 4
- structs with VariableLengthInlineArray and SizeOf(0) HOT 4
- CsWin32 generates `SafeHandle` parameter for `LPPROC_THREAD_ATTRIBUTE_LIST` in `CreateRemoteThreadEx` HOT 6
- SafeHandle overload should be generated for functions with `out` parameters HOT 5
- SetupDiGetDeviceInterfaceDetail() throws MashalDirectiveException "Pointers cannot reference marshaled structures" HOT 7
- COM Out arguments in DXGI/D3D11 are suddenly unmanaged HOT 4
- Publish WPF Desktop App not possible HOT 15
- IShellItemImageFactory.GetImage should return HRESULT HOT 1
- Add support for MAKEPOINTS, GET_X_LPARAM, GET_Y_LPARAM macros HOT 1
- APPBARDATA should compile on AnyCPU HOT 2
- CsWin32 should avoid Unsafe.SkipInit when it doesn't exist in the compilation HOT 1
- WlanOpenHandle doesn't support SafeHandle HOT 1
- The API "Gdi32" is ambiguous HOT 4
- Add `GET_WHEEL_DELTA_WPARAM` macro
- `TASKDIALOGCONFIG.pfCallback` should use associated enum for `msg` parameter
- Broken `VariableLengthInlineArray<T>` after upgrade from 0.3.49-beta to 0.3.106 HOT 8
- NetFramework - Unsafe.SkipInit(out T value) unavailable HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cswin32.