LegacyWrapper
LegacyWrapper copied to clipboard
Invalid pointer error for void *lp parameter
I used a 32 bit DLL method that has void *lp parameter. When IntPtr returned by Marshall.StructureToPtr was passed, DLL method returned invalid pointer error.
Solution is to cast structure to byte array, create a pointer in Codefoundry.LegacyWrapper32 process memory and pass this pointer to DLL method.
Process legacyWrapper32 = Process.GetProcessesByName("Codefoundry.LegacyWrapper32")[0];
IntPtr pnt = Internals.VirtualAllocEx(legacyWrapper32.Handle, IntPtr.Zero, buf.Length, Internals.AllocationType.Commit | Internals.AllocationType.Reserve, Internals.MemoryProtection.ReadWrite);