c++ - Most efficient replacement for IsBadReadPtr? -


I have some visual C ++ code that receives an indicator in the buffer with data that is processed by my code And the length of that buffer due to a bug outside of my control, sometimes this indicator starts in my code or is otherwise unusable to read (i.e. when I try to access data in buffer ).

Therefore, I need to be before I use it, to verify this indicator. I do not want to use IsBadReadPtr or IsBadWritePtr because everyone agrees that they are buggy (Google for example them.) They are also not thread-safe - probably there is no worry in this case, although a thread-safe The solution would be nice.

I have suggested netting to complete this by using a virtualaxy or by simply doing a memix inside the exception handler, although the code where it should be checked, it is time sensitive so that I have the most effective check Which is also 100% effective. Any thoughts would be appreciated.

Just to be clear: I know that the best practice is to just read the bad pointer, after creating an exception, find back to that source and fix the real problem. However, in this case bad pointers are coming from Microsoft code which I do not have control, so I have to verify them.

Also keep in mind that if the data is pointed. My code is searching for specific data patterns and will ignore data if they are not found. I'm just trying to stop the accident after running memcpy on this data, and try to handle exception in the point mempi, my code will need to replace a dozen places (but if I call There was something like IsBadReadPtr for so I would only have to change the code in one place).

A thread-safe solution would be good

I think it's only Isabroitprint That is not thread-safe.

Just make a memix inside an exception handler

It's effectively, what IsBadReadPtr is doing ... and if you want to do it with your code , Your code will have the same bug as the IsBadReadPtr implementation:

- Edit: -

of IBadReadPtr which I have read The only problem with this is that bad indicators (either you can accidentally touch) guard page of a stack, maybe you can avoid this problem (and Use the IbsbadpT to securely), by:

  • Find out which formulas are running in your process
  • Find out where the threads of thread are, And how big they are
  • Walk down each stack, at least once before touching each page of the stack, before starting to call, BADReadPtr

In addition, the comments associated with the above mentioned URL also suggest the use of virtualization And do.


Comments