marshalling

Marshal unserialization - not secure

梦想与她 提交于 2019-12-19 06:23:02
问题 I work on a project where I use cPickle to load files quickly. A couple of days ago I read that marshal can be even faster than cPickle . It works for me, but I'm curious, what is this warning from the documentation about: Warning The marshal module is not intended to be secure against erroneous or maliciously constructed data. Never unmarshal data received from an untrusted or unauthenticated source. What could exactly happen if I'm not careful? 回答1: Marshal There are no known ways to

Marshal unserialization - not secure

江枫思渺然 提交于 2019-12-19 06:21:08
问题 I work on a project where I use cPickle to load files quickly. A couple of days ago I read that marshal can be even faster than cPickle . It works for me, but I'm curious, what is this warning from the documentation about: Warning The marshal module is not intended to be secure against erroneous or maliciously constructed data. Never unmarshal data received from an untrusted or unauthenticated source. What could exactly happen if I'm not careful? 回答1: Marshal There are no known ways to

Marshal ruby hash with default proc - remove the default proc?

梦想的初衷 提交于 2019-12-19 05:23:39
问题 I've got a Hash with a default proc that I'd like to Marshal to a file, but the default proc prevents me from doing that. Rather than writing my own _dump and _load methods, is it possible instead to remove the default proc instead? At the point where I'm Marshalling I'm never going to need the default proc again. 回答1: Just reset the default: h.default = nil More explicitly: def dumpable_hash(h) return h unless h.default_proc copy = h.clone copy.default = nil # clear the default_proc copy end

What is required to enable marshaling for a COM interface?

旧时模样 提交于 2019-12-19 03:59:20
问题 I have a 32-bit ATL COM component without a type library. It has a class factory for one given class that implements several interfaces. When I use it as an in-proc server, everything works fine - the client side invokes CoCreateInstance(), the object is instantiated and QueryInterface() retrieves a pointer to a requested interface. But when I put the component into COM+ I no longer can instantiate the class - CoCreateInstance() now returns E_NOINTERFACE. I believe the problem is that COM+

Marshalling array of strings to char ** in C#

余生长醉 提交于 2019-12-19 03:19:25
问题 I'm calling a C DLL function and need to supply the following C struct: typedef struct { char *mTableId; char **mFieldNames; int mNumFields; char *mFilter; char *mSort; int mOffset; int mMaxRecords; char *mTargetRecordFilter; int mSurroundingRecordsCount; int *mOwnerIds; int mNumOwnerIds; gsi_bool mCacheFlag; } SAKESearchForRecordsInput; The problem is with char **mFieldNames; I've tried marshalling automatically like this: [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPTStr

Returning pointers from unmanaged to managed code

…衆ロ難τιáo~ 提交于 2019-12-19 02:31:20
问题 I've an unmanaged dll that exports the folowing function: SomeData* test(); Let's assume SomeData as: typedef struct _Data Data; struct _Data{ int a; int b; } Now i want to call this function from C# code. I start to define the C# Struture needed to custom marshaling like this: [StructLayout(LayoutKind.Sequential)] public class SomeData { public Int32 a; public Int32 b; } And now, i declare the managed function: [DllImport("DynamicLibrary.dll", CharSet=CharSet.Auto)] [return: MarshalAs

float* from C to C#

夙愿已清 提交于 2019-12-19 02:15:11
问题 I'm not truly a CS guy, so if any of you geniuses on here can point me in the right direction I'll be eternally grateful. I have a c-code command line function that used to write its results to file. I converted it to return it's data via a float* array to a C++ program like such (to avoid constant file I/O): float * mgrib(int argc, char **argv) This worked perfectly. I now need to get this into a C# program, and here's where things go haywire. The first thing I did to avoid the char ** was

float* from C to C#

蓝咒 提交于 2019-12-19 02:15:06
问题 I'm not truly a CS guy, so if any of you geniuses on here can point me in the right direction I'll be eternally grateful. I have a c-code command line function that used to write its results to file. I converted it to return it's data via a float* array to a C++ program like such (to avoid constant file I/O): float * mgrib(int argc, char **argv) This worked perfectly. I now need to get this into a C# program, and here's where things go haywire. The first thing I did to avoid the char ** was

JAXB @XmlAdapter: Map -> List adapter? (marshall only)

邮差的信 提交于 2019-12-18 16:30:46
问题 I have a Map<String, String> . The first idea everyone has is to convert it to a List<Pair<String,String>> ( Pair being a custom class). I've tried a @XmlAdapter like this: public class MapPropertiesAdapter extends XmlAdapter<List<Property>, Map<String,String>> { ... } But Eclipse MOXy, the JAXB impl I use, ended up with a ClassCastException - "can't convert HashMap to Collection". Is this conversion supported by JAXB? Or did I overlook some documentation part which explains why it isn't? PS:

What are the C# equivalent of these C++ structs

有些话、适合烂在心里 提交于 2019-12-18 12:39:01
问题 typedef union _Value { signed char c; unsigned char b; signed short s; unsigned short w; signed long l; unsigned long u; float f; double *d; char *p; } Value; typedef struct _Field { WORD nFieldId; BYTE bValueType; Value Value; } Field; typedef struct _Packet { WORD nMessageType; WORD nSecurityType; BYTE bExchangeId; BYTE bMarketCenter; int iFieldCount; char cSymbol[20]; Field FieldArr[1]; } Packet; What are the C# equivalent of these C++ structs? I am migrating some code from C++ to C# and