-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about mixing MemorySharp and P/Invoke method #27
Comments
Hey, I'm unsure if you can call Could you please try to modify the delegate type to return an Cheers |
Hello and thanks for your time :)
Now, i have a result, but it is incomplete.
This call return "BFEBFBFF000906EA" where the Memory sharp call with the ptr modification return only the first part (BFEBFBFF) At this point, if i try to marshal the IntPtr to my result struc, i have the following erreor message: I have updated the sample project in attachment. Hope this can help |
Indeed, on 32-bit systems, registers are 4-byte long. Since you need more than 4 bytes, you will need to pass the pointer of a buffer as an argument where you can freely assign values. Modify one more time your delegate to receive a pointer of unmanaged memory. The type of this parameter will be Finally, when the call of EDIT: Use |
Correct, I meant to evaluate the size of The value to read as
This is also something that is needed. You have allocated a buffer of memory that you passed to your assembly code. You now need to save the values you are interested in that buffer. This requires you to modify your assembly code to write the CPUID values inside that region of memory. Once your assembly code returns, you will use MemorySharp to read that filled buffer into your managed code, using that Said otherwise, you need a temporary memory buffer to store more than 4 bytes. This is your variable Another point regarding the |
I modify my code to use MemorySharp instead.
Here is the code:
I end with the same problem, if i execute this code first, i have a value in
If i made a call to a P/Invoke method first, the struct CpuIdResult has all this properties to 0.
When i first call MemorySharp
When i call a P/Invoke method before calling MemorySharp:
Here is the modified example /repro project.
ConsoleApp1.zip
I'm pretty sure i'm missing something but what...
I hope you will have the time to take a look, and maybe a lead for me
Originally posted by @smardine in #26 (comment)
The text was updated successfully, but these errors were encountered: