C
C#13mo 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
Aaron13mo 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
Kleidukos13mo ago
I dont know how i can recode this because of the pointers
Aaron
Aaron13mo ago
the parameters seem to just be arrays
Kleidukos
Kleidukos13mo ago
Maybe using unsafe context and the pointers in c#
Aaron
Aaron13mo ago
everything else seems like it could just be an index into those arrays no pointers needed
Kleidukos
Kleidukos13mo ago
pInput + 1 means this the pointer is shifted to the next element ?
Aaron
Aaron13mo ago
essentially, yes
Kleidukos
Kleidukos13mo ago
Thanks, i will give it a try What is the difference between
pInput + 1
And
pInput[1]
phaseshift
phaseshift13mo ago
not much, most of the time
Kleidukos
Kleidukos13mo ago
When i use pInput + 1, is the pointer constant shifted ?
phaseshift
phaseshift13mo ago
is pinput a constant? and yes, it's incremented by the element size
Kleidukos
Kleidukos13mo ago
no
phaseshift
phaseshift13mo ago
then what do you mean 'pointer constant'?
Kleidukos
Kleidukos13mo ago
When i call pInput + 1 Will it the same value when i call after taht pInput
phaseshift
phaseshift13mo ago
I cant understand the question
Kleidukos
Kleidukos13mo ago
Will the pointer stay in the new position or goes back after the call
phaseshift
phaseshift13mo ago
'the pointer'? 'x+1' doesnt change x
Kleidukos
Kleidukos13mo ago
0x00000 <- pointer is here pointer + 1 0x00001 <- pointer is here print(pointer) Will it print 0x00000 or 0x00001 Its only pseudo code
phaseshift
phaseshift13mo ago
0x00001 <- pointer is here
no, 'pointer' didnt change x=0; x+1; print(x); did you change x?
Kleidukos
Kleidukos13mo ago
No Then this means i got only the value from adress 0x00000 with the offset 1 (0x00001)
Accord
Accord13mo 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.