Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // typedef struct _PUBLICKEYSTRUC
- // {
- // BYTE bType;
- // BYTE bVersion;
- // WORD reserved;
- // ALG_ID aiKeyAlg;
- // } BLOBHEADER, PUBLICKEYSTRUC;
- [StructLayout(LayoutKind.Sequential)]
- public struct PUBLICKEYSTRUC
- {
- public Byte bType;
- public Byte bVersion;
- public Int16 reserved;
- public Int32 aiKeyAlg;
- }
- //typedef struct __KEYBLOB
- //{
- // BLOBHEADER hdr;
- // DWORD cbKeySize;
- // BYTE* rgbKeyData;
- //} KEYBLOB;
- [StructLayout(LayoutKind.Sequential)]
- public struct KEYBLOB
- {
- public PUBLICKEYSTRUC hdr;
- public Int16 cbKeySize;
- public Byte[] rgbKeyData;
- }
- int len = (Marshal.SizeOf(typeof(PUBLICKEYSTRUC) + Marshal.SizeOf(typeof(KEYBLOB)) + KeySize;
- byte[] arr = new byte[len];
- IntPtr ptr = Marshal.AllocHGlobal(len);
- Marshal.StructureToPtr(keyBlob, ptr, true);
- Marshal.Copy(ptr, arr, 0,len);
- Marshal.FreeHGlobal(ptr);
Add Comment
Please, Sign In to add comment