C
C#2y ago
Kleidukos

❔ system.accessviolationexception: attempted to read or write protected memory

I created an c++ dll to call this -> https://pastes.dev/MIdnPDHsBs from C# But i get this exception
system.accessviolationexception: "attempted to read or write protected memory. this is often an indication that other memory is corrupt."
What i am doing wrong and how can i solve this Should i try to code this in C# ?
21 Replies
Aaron
Aaron2y ago
I would generally try to avoid having to do interop with native if you can in any case, that's just C#'s way of saying segfault
Kleidukos
KleidukosOP2y ago
I dont know how i can recode this because of the pointers
Aaron
Aaron2y ago
the parameters seem to just be arrays
Kleidukos
KleidukosOP2y ago
Maybe using unsafe context and the pointers in c#
Aaron
Aaron2y ago
everything else seems like it could just be an index into those arrays no pointers needed
Kleidukos
KleidukosOP2y ago
pInput + 1 means this the pointer is shifted to the next element ?
Aaron
Aaron2y ago
essentially, yes
Kleidukos
KleidukosOP2y ago
Thanks, i will give it a try What is the difference between
pInput + 1
And
pInput[1]
phaseshift
phaseshift2y ago
not much, most of the time
Kleidukos
KleidukosOP2y ago
When i use pInput + 1, is the pointer constant shifted ?
phaseshift
phaseshift2y ago
is pinput a constant? and yes, it's incremented by the element size
Kleidukos
KleidukosOP2y ago
no
phaseshift
phaseshift2y ago
then what do you mean 'pointer constant'?
Kleidukos
KleidukosOP2y ago
When i call pInput + 1 Will it the same value when i call after taht pInput
phaseshift
phaseshift2y ago
I cant understand the question
Kleidukos
KleidukosOP2y ago
Will the pointer stay in the new position or goes back after the call
phaseshift
phaseshift2y ago
'the pointer'? 'x+1' doesnt change x
Kleidukos
KleidukosOP2y ago
0x00000 <- pointer is here pointer + 1 0x00001 <- pointer is here print(pointer) Will it print 0x00000 or 0x00001 Its only pseudo code
phaseshift
phaseshift2y ago
0x00001 <- pointer is here
no, 'pointer' didnt change x=0; x+1; print(x); did you change x?
Kleidukos
KleidukosOP2y ago
No Then this means i got only the value from adress 0x00000 with the offset 1 (0x00001)
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server