private static PRE_Cipher CipherPtr2CipherStr(IntPtr C) { PRE_ptrCipher CC = (PRE_ptrCipher)Marshal.PtrToStructure(C, typeof(PRE_ptrCipher)); String e = Marshal.PtrToStringAuto(CC.E, CipherBlockSize); String f = Marshal.PtrToStringAnsi(CC.F); String u = Marshal.PtrToStringAnsi(CC.U); String w = Marshal.PtrToStringAnsi(CC.W); return(new PRE_Cipher { E = e, F = f, U = u, W = w }); }
private static IntPtr CipherStr2CipherPtr(PRE_Cipher CC) { PRE_ptrCipher ptrC = new PRE_ptrCipher { E = Marshal.StringToHGlobalAuto(CC.E), F = Marshal.StringToHGlobalAnsi(CC.F), U = Marshal.StringToHGlobalAnsi(CC.U), W = Marshal.StringToHGlobalAnsi(CC.W), }; IntPtr C = Marshal.AllocHGlobal(Marshal.SizeOf(ptrC)); Marshal.StructureToPtr(ptrC, C, true); return(C); }
private static IntPtr CipherStr2CipherPtr( PRE_Cipher CC ) { PRE_ptrCipher ptrC = new PRE_ptrCipher { E = Marshal.StringToHGlobalAuto( CC.E ) , F = Marshal.StringToHGlobalAnsi( CC.F ) , U = Marshal.StringToHGlobalAnsi( CC.U ) , W = Marshal.StringToHGlobalAnsi( CC.W ) , }; IntPtr C = Marshal.AllocHGlobal( Marshal.SizeOf( ptrC ) ); Marshal.StructureToPtr( ptrC , C , true ); return C; }