Hi, I am creating an array as below:
public struct Smb_Parameters
{
public byte WordCount;
public ushort[] Words;
}
While I assign the values Like below:
Smb_Parameters smbParameter = new Smb_Parameters();
smbParameter.WordCount = 0;
string words= "NT LM 0.12";
smbParameter.Words = Encoding.ASCII.GetBytes(name);
In the above assignment smbParameter.WordCount
contains the value 0
but does smbParameter.Words
contains directly the values(Arry of byteS) or memory reference to the location that contains the values?
Edit 1:
I want to send a packet to the server . For that I need to convert Smb_Parameters
object to array using the following code:
int len = Marshal.SizeOf(Smb_Parameters);
byte[] arr = new byte[len];
IntPtr ptr = Marshal.AllocHGlobal(len);
Marshal.StructureToPtr(Smb_Parameters, ptr, true);
Marshal.Copy(ptr, arr, 0, len);
Marshal.FreeHGlobal(ptr);