memlib icon indicating copy to clipboard operation
memlib copied to clipboard

Replace useless NilAccessDefect with useful LibraryError

Open theAkito opened this issue 3 years ago • 2 comments

First of all, thank you for yet another great library!

I wanted to contribute at least a bit, by fixing an issue I found when testing this library. 😃

theAkito avatar May 31 '21 01:05 theAkito

Thank you for this PR! My questions:

  1. How do you let LoadLibraryA(cname) raise a NilAccessDefect? bad DLL?
  2. Is there other codes that cause useless exception instead of LibraryError for bad DLL?

khchen avatar May 31 '21 10:05 khchen

Thank you for this PR! My questions:

  1. How do you let LoadLibraryA(cname) raise a NilAccessDefect? bad DLL?
  2. Is there other codes that cause useless exception instead of LibraryError for bad DLL?
  1. To be honest, I'm still puzzled. After this Patch, it's telling me that it can't find "KERNEL32.dll" -- even though, this should be impossible, as far as I understand.
  2. Yes, there are other places in the code that could be improved by replacing NilAccessDefect with something meaningful, but I did not know about the others yet, when I opened this PR.

If you think this method for making more useful exceptions is helpful, perhaps it would be even better if all places where a NilAccessDefect could possibly be found would be improved by a more meaningful exception, in the same way as done in this commit (try catch all the possible failures)?

To put all this in context: I was playing around with the openssl example, because I wanted to test if I can embed the library into the executable with memlib. However, I am still struggling to get it to work.

theAkito avatar May 31 '21 12:05 theAkito