Questions tagged [structlayout]

49 questions
0
votes
0 answers

C# StructLayout Pack get System.NullReferenceException, alignement issue?

First of all, I would say that, I'm not stuck, as there is a lot of workaround for me !! The best of then is that I don't need 1Byte Pack anymore :P But honestly, I'm quite puzzle about the behavior. I'm using Unity, It works perfectly on Windows…
Jan
  • 91
  • 4
0
votes
1 answer

C# pack 1 StructLayout networking

I am trying to send a buffer from a server to client which I have made by myself. It works with sockets on TCP. I have a struct that I need to send: [StructLayout(LayoutKind.Sequential, Pack = 1)] struct loginStruct { public string userName; …
user2320928
  • 279
  • 1
  • 7
  • 17
0
votes
2 answers

PInvoke for DWORD-aligned handles to memory

I was trying to write a C# equivalent for ACCESS_DENIED_ACE struct as defined in MSDN: typedef struct _ACCESS_DENIED_ACE { ACE_HEADER Header; ACCESS_MASK Mask; DWORD SidStart; } ACCESS_DENIED_ACE, *PACCESS_DENIED_ACE; Where SidStart is…
sri
  • 1,005
  • 1
  • 12
  • 26
-1
votes
1 answer

undefined behaviour with StructLayout and FieldOffset

I have extracted with success a structure object from a valid pointer using the PtrToStructure function (in VB.NET), but the result of some object members are not correct (comparing with the C++ example): the code is…
1 2 3
4