Issues related to VMProtect
sys_dev
Posts: 20 Joined: Tue Sep 03, 2013 8:08 am
Post
by sys_dev » Tue Dec 01, 2015 9:25 am
Мы хотим купить последнюю версию VmProtect v3, но при просмотре версии v.3.0.6 build 537 Demo мы столкнулись с ошибкой.
В проблемном куске кода(см.ниже) приведены тестовые ситуации, которые мы попробовали. Вместо ожидаемых результатов в catch-блоках мы получаем ошибку 'Illegal instruction'.
Code: Select all
#include <stdio.h>
#include "VMProtectSDK.h"
#include <exception>
#pragma GCC push_optimize
#pragma GCC optimize("O0")
void testFunction( int n )
{
// trying to write complex code to avoid inlining
for( int i = 0; i < n; ++i )
{
if( i < 1000 )
{
throw 1;
}
i = ( ++i ^ 15 ) * 42;
}
}
int main( int argc, char** argv )
{
printf( "Test started\n" );
try
{
VMProtectBeginVirtualization( "" );
testFunction( argc );
//throw 1;
//throw std::exception();
VMProtectEnd();
}
catch( int )
{
printf( "OK - catch( int ) exception correctly!\n" );
}
catch( const std::exception& )
{
printf( "OK - catch( std::exception ) exception correctly!\n" );
}
printf( "Test finished\n" );
return 0;
}
#pragma GCC pop_optimize
Информация о OS X:
Darwin Tests-Mac.local 15.0.0 Darwin Kernel Version 15.0.0: Wed Aug 26 16:57:32 PDT 2015; root:xnu-3247.1.106~1/RELEASE_X86_64 x86_64
и GCC:
Using built-in specs.
COLLECT_GCC=/usr/local/Cellar/gcc49/4.9.3/bin/gcc-4.9
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc49/4.9.3/libexec/gcc/x86_64-apple-darwin15.0.0/4.9.3/lto-wrapper
Target: x86_64-apple-darwin15.0.0
Configured with: ../configure --build=x86_64-apple-darwin15.0.0 --prefix=/usr/local/Cellar/gcc49/4.9.3 --libdir=/usr/local/Cellar/gcc49/4.9.3/lib/gcc/4.9 --enable-languages=c,c++,objc,obj-c++ --program-suffix=-4.9 --with-gmp=/usr/local/opt/gmp4 --with-mpfr=/usr/local/opt/mpfr2 --with-mpc=/usr/local/opt/libmpc08 --with-cloog=/usr/local/opt/cloog018 --with-isl=/usr/local/opt/isl011 --with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --with-build-config=bootstrap-debug --disable-werror --with-pkgversion='Homebrew gcc49 4.9.3' --with-bugurl=
https://github.com/Homebrew/homebrew-versions/issues --enable-plugin --disable-nls --enable-multilib
Thread model: posix
gcc version 4.9.3 (Homebrew gcc49 4.9.3)
vmp-файл:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<Document>
<Protection
InputFileName="a4.out"
Options="0"
CheckKernelModeDebugger="false"
CompressionMode="0"
VMCodeSectionName=".vmp"
VMExecutorCount="1"
OutputFileName=""
>
<Messages
/>
<Folders
/>
<Procedures
/>
</Protection>
<Script
/>
</Document>
Admin
Site Admin
Posts: 2585 Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:
Post
by Admin » Tue Dec 01, 2015 10:26 am
Присылайте тестовый пример (оригинальный EXE+VMP файлы), на котором воспроизводится эта проблема
sys_dev
Posts: 20 Joined: Tue Sep 03, 2013 8:08 am
Post
by sys_dev » Tue Dec 01, 2015 10:35 am
Присылайте тестовый пример (оригинальный EXE+VMP файлы), на котором воспроизводится эта проблема
ОК. Архив в аттаче
Attachments
vmp3-error.7z
(238.25 KiB) Downloaded 343 times
Admin
Site Admin
Posts: 2585 Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:
Post
by Admin » Wed Dec 09, 2015 9:06 am
sys_dev
Posts: 20 Joined: Tue Sep 03, 2013 8:08 am
Post
by sys_dev » Tue Dec 29, 2015 6:36 pm
Спасибо, наш пример теперь заработал!
Но есть два других примера, которые по-прежнему не работают:
Тест 1:
Code: Select all
#include <stdio.h>
#include "VMProtectSDK.h"
#include <exception>
#pragma GCC push_optimize
#pragma GCC optimize("O0")
int main( int argc, char** argv )
{
printf( "Test started\n" );
try
{
VMProtectBeginVirtualization( "" );
throw 1;
VMProtectEnd();
}
catch( int )
{
printf( "OK - catch( int ) exception correctly!\n" );
}
catch( const std::exception& )
{
printf( "OK - catch( std::exception ) exception correctly!\n" );
}
printf( "Test finished\n" );
return 0;
}
#pragma GCC pop_optimize
Тест 2:
Code: Select all
#include <stdio.h>
#include "VMProtectSDK.h"
#include <exception>
#pragma GCC push_optimize
#pragma GCC optimize("O0")
int main( int argc, char** argv )
{
printf( "Test started\n" );
try
{
VMProtectBeginVirtualization( "" );
if( argc < 1000 )
{
throw 1;
}
VMProtectEnd();
}
catch( int )
{
printf( "OK - catch( int ) exception correctly!\n" );
}
catch( const std::exception& )
{
printf( "OK - catch( std::exception ) exception correctly!\n" );
}
printf( "Test finished\n" );
return 0;
}
#pragma GCC pop_optimize
Скажите это можно поправить?
Архив со всеми файлами по ссылке:
https://yadi.sk/d/rU3tBETeman8U
P.S. с наступающим Вас Новым Годом!
Admin
Site Admin
Posts: 2585 Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:
Post
by Admin » Mon Jan 04, 2016 8:41 am
Так лучше не писать:
VMProtectBeginVirtualization( "" );
throw 1;
VMProtectEnd();
Все что идет после throw становится мертвым кодом (оптимизатор выкинул VMProtectEnd()).
Admin
Site Admin
Posts: 2585 Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:
Post
by Admin » Tue Jan 05, 2016 8:26 am