Skip to content
This repository has been archived by the owner on Nov 27, 2019. It is now read-only.

获取post请求数据 #8

Open
liuhongwei opened this issue Sep 18, 2019 · 1 comment
Open

获取post请求数据 #8

liuhongwei opened this issue Sep 18, 2019 · 1 comment

Comments

@liuhongwei
Copy link

你好,blink要获取post内容有什么方式么?
通过api 找到了wkeNetGetPostBody,应该是这个函数,但是尝试多次没能够调用成功。

也参考了以下代码,尝试多次调试不能正常运行,如果调用,请给点资料,谢谢。

获取post数据:
var eles = (wkePostBodyElements)Marshal.PtrToStructure(BlinkBrowserPInvoke.wkeNetGetPostBody(job), typeof(wkePostBodyElements));

                    int size = Marshal.SizeOf(typeof(wkePostBodyElement)) * eles.elementSize;
                    IntPtr pBuff = Marshal.AllocHGlobal(size);
                    wkePostBodyElement[] lst = new wkePostBodyElement[eles.elementSize];

                    for (var i = 0; i < eles.elementSize; i++)
                    {
                        IntPtr ptr = new IntPtr(pBuff.ToInt64() + Marshal.SizeOf(typeof(wkePostBodyElement)) * i);
                        lst[i] = (wkePostBodyElement)Marshal.PtrToStructure(ptr, typeof(wkePostBodyElement));
                        var dataPtr = lst[i].data;
                        var data = (wkeMemBuf)Marshal.PtrToStructure(dataPtr, typeof(wkeMemBuf));//这行报错:尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

                        //var str = Marshal.PtrToStringAuto(lst[i].data);
                    }
@E024
Copy link
Owner

E024 commented Sep 19, 2019

int size = Marshal.SizeOf(typeof(wkePostBodyElement)) * eles.elementSize;
你这行为什么还要乘 wkePostBodyElement 的大小?应该直接 eles.elementSize 就好了。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants