From 18ef040aba06819090579bdd2ed72c26834f78ac Mon Sep 17 00:00:00 2001 From: theAkito Date: Mon, 31 May 2021 03:26:37 +0200 Subject: [PATCH 1/2] Replace useless NilAccessDefect with useful LibraryError Raising the `LibraryError` in line 313 shows exactly what library failed to load. If the `handle` variable assignment excepts, due to a `NilAccessDefect`, then you first have to debug the flow of your program to find the issue. Therefore, we catch the exception and raise a meaningful error, that is telling you exactly why the `LoadLibraryA` proc failed to execute. --- memlib.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memlib.nim b/memlib.nim index a24eae8..fb4b7a8 100644 --- a/memlib.nim +++ b/memlib.nim @@ -307,7 +307,7 @@ proc buildImportTable(lib: MemoryModule) {.raises: [LibraryError].} = for desc in codeBase.descriptors(directory): let cname = codeBase{desc.Name}[LPCSTR] - handle = LoadLibraryA(cname) + handle = try: LoadLibraryA(cname) except: 0 if handle == 0: raise newException(LibraryError, $cname & " not found") From 71fac1c5c8a2bdcd2fee4f8fd0fc3a69ec89b4e9 Mon Sep 17 00:00:00 2001 From: theAkito Date: Mon, 31 May 2021 03:27:32 +0200 Subject: [PATCH 2/2] 1.0.1 Bump Version --- memlib.nimble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memlib.nimble b/memlib.nimble index adf744f..2bcc02c 100644 --- a/memlib.nimble +++ b/memlib.nimble @@ -1,6 +1,6 @@ # Package -version = "1.0.0" +version = "1.0.1" author = "Ward" description = "Memlib - Load Windows DLL from memory" license = "MIT"