WinAPI emulation

Post here messages if you have any problems with working of Enigma Protector
Post Reply
rconn
Posts: 19
Joined: Wed Dec 10, 2008 4:38 pm

WinAPI emulation

Post by rconn »

I have some code that does a LoadLibrary call when passed an (optional) plugin name. If "Use WinAPI functions emulation" is enabled and LoadLibrary fails, GetLastError() always returns 0, which makes it impossible to determine the error.

Rex Conn
JP Software
Enigma
Site Admin
Posts: 2945
Joined: Wed Aug 20, 2008 2:24 pm

Re: WinAPI emulation

Post by Enigma »

Rex, does this error occur in the application that you sent me? Could you please tell me the steps how to reproduce this error? I assume that API Emulation option hooks LoadLibrary API, but the hook code is such simple, I even can't understand where error might occur.
rconn
Posts: 19
Joined: Wed Dec 10, 2008 4:38 pm

Re: WinAPI emulation

Post by rconn »

The dll that I sent you for the hanging problem has a kludge that I added to force the error code from 0 to 126 on an error. The download link (the original, protected file) shows the error if you do:

plugin /l waffles

The plugin "waffles" doesn't exist and LoadLibrary returns NULL, but GetLastError() returns 0 so the error message is "The operation completed successfully".

I suspect there's another Windows API call after the LoadLibrary, which is resetting GetLastError() before returning to my app. I've had similar situations where I need to save the error code after an API, do some cleanup, then call SetLastError() with the saved error so that the calling function can get the correct error.

Rex Conn
JP Software
Enigma
Site Admin
Posts: 2945
Joined: Wed Aug 20, 2008 2:24 pm

Re: WinAPI emulation

Post by Enigma »

Yes Rex, you are absolutely right, there is a call of other Win API after the LoadLibrary call, so error code is overloaded and incorrect. I knew about this bug and already had same deal with CreateFile functions. Now this issue is solved. Thanks for the information.

PS: I planed to release 1.70 next version, but as I collected few more bugs, seems 1.66 will be released soon.
Post Reply