Some VMProtectDecryptString calls are not detected by VMP
Posted: Mon Aug 26, 2013 12:12 pm
I've come across an issue due to which some VMProtectDecryptStrings() protected strings show up in the UI for protection, while others don't.
The issue goes away when using #pragma optimize("g", off), however that's no good workaround when having lots of rarely used error messages in frequently called functions.
The string functions are called through registers, but that's been fixed a long time ago, according to this thread:
Later on those functions aren't called directly like this:
... but like this:
This code appears to occur due to the way MSVC performs exception handling. In each local block, which contains a protected string, I also create some temporary object, which must be destroyed in case of an exception. MSVC seems to keep track of it using an invisible local variable in the function.
The "mov" disappears if I move the creation of the temporary error-object out of the conditional scope that triggers the message.
It would be really nice if the VMP protected string detection could be adapted, so strings like those (and I have many of them, as error handling is performed through a macro), are protected as well.
If it can't be fixed, it should at least be detected. So if VMP comes across an ESI/EDI call to DecryptString, which doesn't seem to reference any actual string, it should display a warning, along with the disassembly of the function, so a workaround can be made in the source code.
The issue goes away when using #pragma optimize("g", off), however that's no good workaround when having lots of rarely used error messages in frequently called functions.
The string functions are called through registers, but that's been fixed a long time ago, according to this thread:
Code: Select all
00F6E6F4 mov esi,dword ptr [__imp__VMProtectDecryptStringA@4 (11CF910h)]
00F6E6FA mov edi,dword ptr [__imp__VMProtectFreeString@4 (11CF914h)]
Code: Select all
00F6E75F push offset string "Trial version expired"... (124D508h)
00F6E764 call esi
Code: Select all
00F6E75F push offset string "Trial version expired"... (124D508h)
00F6E764 mov byte ptr [ebp-4],3
00F6E768 call esi
00F6E7AF push offset string "License corrupted"... (124D4CCh)
00F6E7B4 mov byte ptr [ebp-4],5
00F6E7B8 call esi
The "mov" disappears if I move the creation of the temporary error-object out of the conditional scope that triggers the message.
It would be really nice if the VMP protected string detection could be adapted, so strings like those (and I have many of them, as error handling is performed through a macro), are protected as well.
If it can't be fixed, it should at least be detected. So if VMP comes across an ESI/EDI call to DecryptString, which doesn't seem to reference any actual string, it should display a warning, along with the disassembly of the function, so a workaround can be made in the source code.