aboutsummaryrefslogtreecommitdiff
path: root/unit-tests
diff options
context:
space:
mode:
authorjmpoep <OriginalEntryPoint@qq.com>2023-12-07 16:51:07 +0800
committerjmpoep <OriginalEntryPoint@qq.com>2023-12-07 16:51:07 +0800
commit28008a746a31abb7909dd86cb0cd413ac8943b0b (patch)
treea30b74b8cad548048c3c1551d652828ab76fa9bd /unit-tests
downloadvmprotect-3.5.1-master.tar
vmprotect-3.5.1-master.tar.gz
vmprotect-3.5.1-master.tar.bz2
vmprotect-3.5.1-master.zip
first commitHEADmaster
Diffstat (limited to 'unit-tests')
-rw-r--r--unit-tests/arm_tests.cpp60
-rw-r--r--unit-tests/core_tests.cc87
-rw-r--r--unit-tests/elffile_tests.cc345
-rw-r--r--unit-tests/files_tests.cc405
-rw-r--r--unit-tests/il_tests.cc90
-rw-r--r--unit-tests/intel_tests.cc4493
-rw-r--r--unit-tests/ipn_sqlclr.Test/Properties/AssemblyInfo.cs36
-rw-r--r--unit-tests/ipn_sqlclr.Test/Service References/policyService/CertificateEnrollmentPolicy.wsdl37
-rw-r--r--unit-tests/ipn_sqlclr.Test/Service References/policyService/CertificateEnrollmentPolicy.xsd388
-rw-r--r--unit-tests/ipn_sqlclr.Test/Service References/policyService/Reference.cs3010
-rw-r--r--unit-tests/ipn_sqlclr.Test/Service References/policyService/Reference.svcmap31
-rw-r--r--unit-tests/ipn_sqlclr.Test/Service References/policyService/configuration.svcinfo11
-rw-r--r--unit-tests/ipn_sqlclr.Test/Service References/policyService/configuration91.svcinfo310
-rw-r--r--unit-tests/ipn_sqlclr.Test/Service References/policyService/ipn_sqlclr.Test.policyService.getPoliciesResponse.datasource10
-rw-r--r--unit-tests/ipn_sqlclr.Test/TaggantWebTest.cs129
-rw-r--r--unit-tests/ipn_sqlclr.Test/VmpLicenseKeyTest.cs73
-rw-r--r--unit-tests/ipn_sqlclr.Test/app.config3
-rw-r--r--unit-tests/ipn_sqlclr.Test/ipn_sqlclr.Test.csproj128
-rw-r--r--unit-tests/lin_unit-tests.mak16
-rw-r--r--unit-tests/lin_unit-tests32.mak3
-rw-r--r--unit-tests/lin_unit-tests64.mak3
-rw-r--r--unit-tests/mac_unit-tests.mak16
-rw-r--r--unit-tests/mac_unit-tests32.mak3
-rw-r--r--unit-tests/mac_unit-tests64.mak3
-rw-r--r--unit-tests/macfile_tests.cc462
-rw-r--r--unit-tests/pefile_tests.cc553
-rw-r--r--unit-tests/precompiled.cc1
-rw-r--r--unit-tests/precompiled.h17
-rw-r--r--unit-tests/test1.cc309
-rw-r--r--unit-tests/testfile.h273
-rw-r--r--unit-tests/testfileil.h30
-rw-r--r--unit-tests/testfileintel.h30
32 files changed, 11365 insertions, 0 deletions
diff --git a/unit-tests/arm_tests.cpp b/unit-tests/arm_tests.cpp
new file mode 100644
index 0000000..4043136
--- /dev/null
+++ b/unit-tests/arm_tests.cpp
@@ -0,0 +1,60 @@
+#include "precompiled.h"
+#include "macfile.h"
+#include "arm.h"
+#include "testfile.h"
+
+TEST(ArmFunctionTest, Arm_Test)
+{
+ return;
+
+ MacFile pf(NULL);
+ ArmFunction command_list(NULL, NULL);
+
+ ASSERT_TRUE(pf.Open("test-binaries/ios-app-test2-arm", foRead) == osSuccess);
+ ASSERT_TRUE(pf.count() == 1);
+ IArchitecture &arch = *pf.item(0);
+ ASSERT_TRUE(command_list.ReadFromFile(arch, 0x20B6) == 115);
+ ASSERT_TRUE(command_list.ReadFromFile(arch, 0x345E) == 41);
+ ASSERT_TRUE(command_list.ReadFromFile(arch, 0x1DCD8) == 2);
+}
+
+TEST(ArmFunctionTest, ARM)
+{
+
+ return;
+
+ uint32_t buf[] = {
+ 0xe0006fce, // AND R6, R0, LR,ASR#31
+ 0xe0007064, // AND R7, R0, R4,RRX
+ 0xe0000000, // AND R0, R0, R0
+ 0xe0000001, // AND R0, R0, R1
+ 0xe0000002, // AND R0, R0, R2
+ 0xe0000003, // AND R0, R0, R3
+ 0xe0000004, // AND R0, R0, R4
+ 0xe0000005, // AND R0, R0, R5
+ 0xe0000006, // AND R0, R0, R6
+ 0xe0000007, // AND R0, R0, R7
+ 0xe0000008, // AND R0, R0, R8
+ 0xe0000009, // AND R0, R0, R9
+ 0xe000000a, // AND R0, R0, R10
+ 0xe000000b, // AND R0, R0, R11
+ 0xe000000c, // AND R0, R0, R12
+ 0xe000000d, // AND R0, R0, SP
+ 0xe000000e, // AND R0, R0, LR
+ 0xe000000f, // AND R0, R0, PC
+ 0xe0000010, // AND R0, R0, R0,LSL R0
+ 0xe0000011, // AND R0, R0, R1,LSL R0
+ 0xe0000012, // AND R0, R0, R2,LSL R0
+ 0xe0000013, // AND R0, R0, R3,LSL R0
+ 0xffffffff // INVALID
+ };
+
+ //ArmFunction command_list(NULL, NULL);
+ TestFile test_file(ptArm, osDWord);
+ IArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ TestSegment *segment = segment_list->Add(0x00400000, 0x10000, ".text", mtReadable | mtExecutable);
+ segment->set_physical_size(sizeof(buf));
+ test_file.OpenFromMemory(buf, sizeof(buf));
+ //command_list.ReadFromFile(arch, segment_list->item(0)->address());
+} \ No newline at end of file
diff --git a/unit-tests/core_tests.cc b/unit-tests/core_tests.cc
new file mode 100644
index 0000000..d8ba235
--- /dev/null
+++ b/unit-tests/core_tests.cc
@@ -0,0 +1,87 @@
+#include "../runtime/common.h"
+#include "../runtime/crypto.h"
+#include "../core/objects.h"
+#include "../core/osutils.h"
+#include "../core/streams.h"
+#include "../core/files.h"
+#include "../core/processors.h"
+#include "../core/core.h"
+
+TEST(CoreTest, OpenAndCompile)
+{
+ Core vmp;
+
+ ASSERT_TRUE(vmp.Open("test-binaries/win32-app-test1-i386.vmp"));
+ EXPECT_EQ(vmp.vm_section_name().compare(".test"), 0);
+ IFile &file = *vmp.input_file();
+ ASSERT_EQ(file.count(), 1ul);
+ IArchitecture &arch = *file.item(0);
+ // Check folders.
+ Folder &folder = *file.folder_list();
+ ASSERT_EQ(folder.count(), 2ul);
+ EXPECT_EQ(folder.item(0)->name().compare("Folder1") , 0);
+ EXPECT_EQ(folder.item(1)->name().compare("Folder2") , 0);
+ ASSERT_EQ(folder.item(1)->count(), 1ul);
+ EXPECT_EQ(folder.item(1)->item(0)->name().compare("Strings"), 0);
+ EXPECT_EQ(file.folder_list()->GetFolderList().size(), 3ul);
+ // Check functions.
+ ASSERT_EQ(arch.function_list()->count(), 4ul);
+ EXPECT_EQ(arch.function_list()->item(0)->count(), 6ul);
+ EXPECT_EQ(arch.function_list()->item(1)->folder()->name().compare("Strings"), 0);
+ EXPECT_EQ(arch.function_list()->item(2)->folder()->name().compare("Strings"), 0);
+ // Check external commands.
+ ExtCommandList *ext_command_list = arch.function_list()->item(0)->ext_command_list();
+ ASSERT_EQ(ext_command_list->count(), 2ul);
+ EXPECT_EQ(ext_command_list->item(0)->address(), 0x00401007ull);
+ EXPECT_EQ(ext_command_list->item(1)->address(), 0x00401011ull);
+ ASSERT_TRUE(vmp.Compile());
+}
+
+TEST(CoreTest, CryptRSA)
+{
+ RSA cryptor;
+
+ size_t key_lengths[] = { 1024ul, 1536ul, 2048ul, 2560ul, 3072ul, 3584ul, 4096ul };
+ //for(size_t i = 0; i < _countof(key_lengths); i++)
+ size_t i = rand() % _countof(key_lengths);
+ {
+ size_t key_length = key_lengths[i];
+ ASSERT_TRUE(cryptor.CreateKeyPair(key_length)) << key_length;
+
+ const uint64_t c = 0xDEAD00F00D00AA55ull;
+ Data data;
+ data.PushQWord(c);
+ ASSERT_TRUE(cryptor.Encrypt(data)) << key_length;
+ ASSERT_NE(memcmp(data.data(), &c, sizeof(c)), 0) << key_length;
+ ASSERT_TRUE(cryptor.Decrypt(data)) << key_length;
+ ASSERT_EQ(memcmp(data.data(), &c, sizeof(c)), 0) << key_length;
+ }
+}
+
+TEST(CoreTest, IsUniqueWatermark)
+{
+ WatermarkManager wm(NULL);
+
+ wm.Add("name", "AbCdE?");
+ ASSERT_FALSE(wm.IsUniqueWatermark("AB"));
+ ASSERT_FALSE(wm.IsUniqueWatermark("b?"));
+ ASSERT_FALSE(wm.IsUniqueWatermark("DEF"));
+ ASSERT_FALSE(wm.IsUniqueWatermark("AbCdE?"));
+ ASSERT_FALSE(wm.IsUniqueWatermark("?123?AbCdE8EF"));
+
+ ASSERT_TRUE(wm.IsUniqueWatermark("?B12"));
+ ASSERT_TRUE(wm.IsUniqueWatermark("34587?B123"));
+}
+
+#ifndef VMP_GNU
+TEST(CoreTest, UTF8Validator)
+{
+ ASSERT_TRUE(os::ValidateUTF8(std::string()));
+ ASSERT_TRUE(os::ValidateUTF8(os::ToUTF8(os::unicode_string(L"кириллица"))));
+ ASSERT_FALSE(os::ValidateUTF8(std::string("кириллица 1251")));
+}
+TEST(CoreTest, FromACP)
+{
+ ASSERT_TRUE(os::FromACP(std::string("кириллица 1251")) == os::unicode_string(L"кириллица 1251"));
+}
+#endif \ No newline at end of file
diff --git a/unit-tests/elffile_tests.cc b/unit-tests/elffile_tests.cc
new file mode 100644
index 0000000..6304838
--- /dev/null
+++ b/unit-tests/elffile_tests.cc
@@ -0,0 +1,345 @@
+#include "../runtime/common.h"
+#include "../runtime/crypto.h"
+#include "../core/objects.h"
+#include "../core/osutils.h"
+#include "../core/streams.h"
+#include "../core/core.h"
+#include "../core/files.h"
+#include "../core/processors.h"
+#include "../core/elffile.h"
+#include "../core/lin_runtime32.so.inc"
+#include "../core/lin_runtime64.so.inc"
+
+#ifdef ELFFileTest_TestOpen1
+TEST(ELFFileTest, TestOpen1)
+{
+ ELFFile mf(NULL);
+ ISectionList *segl;
+ ELFSectionList *secl;
+ //ELFSymbolList *syml;
+ IImportList *impl;
+
+ ASSERT_EQ(osSuccess, mf.Open("test-binaries/Project1-linux-x64", true));
+ // Check architectures.
+ EXPECT_EQ(1ul, mf.count());
+ ELFArchitecture &arch = *mf.item(0);
+ EXPECT_EQ("amd64", arch.name());
+ EXPECT_EQ("ELF", arch.owner()->format_name());
+ EXPECT_EQ(0x4007F0ull, arch.entry_point());
+ // Check segments were read.
+ segl = arch.segment_list();
+ struct seg { const char *name; uint32_t mt; } segs[] = {
+ {".interp", mtReadable} // IDA не показывает
+ ,{".init", mtReadable | mtExecutable}
+ ,{".plt", mtReadable | mtExecutable}
+ ,{".text", mtReadable | mtExecutable}
+ ,{".fini", mtReadable | mtExecutable}
+ ,{".rodata", mtReadable}
+ ,{".eh_frame_hdr", mtReadable}
+ ,{".eh_frame", mtReadable}
+ //,{".init_array", mtReadable | mtWritable} - IDA
+ //,{".fini_array", mtReadable | mtWritable} - IDA
+ ,{".jcr", mtReadable | mtWritable}
+ ,{".got", mtReadable | mtWritable}
+ ,{".got.plt", mtReadable | mtWritable}
+ ,{".data", mtReadable | mtWritable}
+ ,{".bss", mtReadable | mtWritable}
+ //,{"extern"} - IDA
+ };
+ ASSERT_EQ(_countof(segs), segl->count());
+ for(size_t i = 0; i < _countof(segs); i++)
+ {
+ EXPECT_EQ(segs[i].name, segl->item(i)->name()) << "i=" << i;
+ EXPECT_EQ(segs[i].mt, segl->item(i)->memory_type()) << "i=" << i;
+ }
+ // Check sections were read.
+ secl = arch.section_list();
+ ASSERT_EQ(0ul, secl->count());
+ //EXPECT_EQ("sn", secl->item(0)->name());
+ // Check symbols.
+ /*syml = arch.symbol_list();
+ ASSERT_EQ(syml->count(), 129ul);
+ EXPECT_EQ(syml->item(0)->name()
+ .compare("/Users/macuser/work2/ios-test2/ios-test2/"), 0);*/
+ // Check imports.
+ impl = arch.import_list();
+ ASSERT_EQ(3ul, impl->count());
+ //Why [0].is_sdk == false?
+ EXPECT_EQ("libVMProtectSDK64.so", impl->item(0)->name());
+ EXPECT_EQ(0ul, impl->item(0)->count());
+ EXPECT_EQ("libc.so.6", impl->item(1)->name());
+ EXPECT_EQ(0ul, impl->item(1)->count());
+ EXPECT_EQ("", impl->item(2)->name());
+ const char *fnames[] = {
+ "__gmon_start__"
+ ,"_Jv_RegisterClasses"
+ ,"puts"
+ ,"__libc_start_main"
+ ,"VMProtectDecryptStringA"
+ ,"fgets"
+ ,"_ITM_deregisterTMCloneTable"
+ ,"_ITM_registerTMCloneTable"
+ ,"atoi"
+ ,"__stack_chk_fail"
+ ,"VMProtectBegin"
+ ,"VMProtectEnd"
+ ,"__gmon_start__"
+ ,"_Jv_RegisterClasses"
+ ,"puts@@GLIBC_2.2.5"
+ ,"__libc_start_main@@GLIBC_2.2.5"
+ ,"VMProtectDecryptStringA"
+ ,"fgets@@GLIBC_2.2.5"
+ ,"_ITM_deregisterTMCloneTable"
+ ,"_ITM_registerTMCloneTable"
+ ,"atoi@@GLIBC_2.2.5"
+ ,"__stack_chk_fail@@GLIBC_2.4"
+ ,"VMProtectBegin"
+ ,"VMProtectEnd"};
+ EXPECT_EQ(_countof(fnames), impl->item(2)->count());
+ for(size_t i = 0; i < _countof(fnames); i++)
+ {
+ EXPECT_EQ(fnames[i], impl->item(2)->item(i)->name()) << "i=" << i;
+ }
+ mf.Close();
+ EXPECT_EQ(mf.count(), 0ul);
+}
+#endif
+
+TEST(ELFFileTest, TestOpen2)
+{
+ ELFFile mf(NULL);
+ ISectionList *segl;
+ ELFSectionList *secl;
+ //ELFSymbolList *syml;
+ IImportList *impl;
+ IExportList *expl;
+
+ ASSERT_EQ(mf.Open("test-binaries/Project1-linux-x86", true), osSuccess);
+ // Check architectures.
+ ASSERT_EQ(mf.count(), 1ul);
+ ELFArchitecture &arch = *mf.item(0);
+ EXPECT_EQ(arch.name().compare("i386"), 0);
+ EXPECT_EQ(arch.owner()->format_name().compare("ELF"), 0);
+ EXPECT_EQ(arch.entry_point(), 0x80485E0ULL);
+ // Check segments were read.
+ segl = arch.segment_list();
+ /*ASSERT_EQ(segl->count(), 4ul);
+ EXPECT_EQ(segl->item(0)->name().compare("__PAGEZERO"), 0);
+ EXPECT_EQ(segl->item(0)->memory_type(), mtNone);
+ EXPECT_EQ(segl->item(1)->name().compare("__TEXT"), 0);
+ EXPECT_EQ((int)segl->item(1)->memory_type(), (mtReadable | mtExecutable));
+ EXPECT_EQ(segl->item(2)->name().compare("__DATA"), 0);
+ EXPECT_EQ((int)segl->item(2)->memory_type(), (mtReadable | mtWritable));
+ EXPECT_EQ(segl->item(3)->name().compare("__LINKEDIT"), 0);
+ EXPECT_EQ(segl->item(3)->memory_type(), mtReadable);*/
+ // Check sections were read.
+ secl = arch.section_list();
+ /*ASSERT_EQ(secl->count(), 10ul);
+ EXPECT_EQ(secl->item(0)->name().compare("__text"), 0);
+ EXPECT_EQ(secl->item(1)->name().compare("__stubs"), 0);
+ EXPECT_EQ(secl->item(2)->name().compare("__stub_helper"), 0);
+ EXPECT_EQ(secl->item(3)->name().compare("__cstring"), 0);
+ EXPECT_EQ(secl->item(4)->name().compare("__unwind_info"), 0);
+ EXPECT_EQ(secl->item(5)->name().compare("__eh_frame"), 0);
+ EXPECT_EQ(secl->item(6)->name().compare("__dyld"), 0);
+ EXPECT_EQ(secl->item(7)->name().compare("__got"), 0);
+ EXPECT_EQ(secl->item(8)->name().compare("__la_symbol_ptr"), 0);
+ EXPECT_EQ(secl->item(9)->name().compare("__data"), 0);
+ // Check symbols.
+ syml = arch.symbol_list();
+ ASSERT_EQ(syml->count(), 57ul);
+ EXPECT_EQ(syml->item(2)->name()
+ .compare("/Users/mac/Library/Developer/Xcode/DerivedData/hello-flxnqzrlabvwqrdcesuuqdaabhfa/Build/Intermediates/hello.build/Release/hello.build/Objects-normal/x86_64/main.o"), 0);*/
+ // Check imports.
+ impl = arch.import_list();
+ /*ASSERT_EQ(impl->count(), 3ul);
+ EXPECT_EQ(impl->item(0)->name().compare("/usr/lib/libstdc++.6.dylib"), 0);
+ EXPECT_EQ(impl->item(1)->name().compare("/usr/lib/libgcc_s.1.dylib"), 0);
+ EXPECT_EQ(impl->item(2)->name().compare("/usr/lib/libSystem.B.dylib"), 0);*/
+ // Check exports.
+ expl = arch.export_list();
+ /*ASSERT_EQ(expl->count(), 5ul);
+ EXPECT_EQ(expl->item(0)->name().compare("_NXArgc"), 0);
+ EXPECT_EQ(expl->item(1)->name().compare("_NXArgv"), 0);
+ EXPECT_EQ(expl->item(2)->name().compare("___progname"), 0);
+ EXPECT_EQ(expl->item(3)->name().compare("_environ"), 0);
+ EXPECT_EQ(expl->item(4)->name().compare("start"), 0);
+ EXPECT_EQ(expl->item(4)->address(), 0x100000c04ULL);*/
+ mf.Close();
+ EXPECT_EQ(mf.count(), 0ul);
+}
+
+/*TEST(ELFFileTest, OpenSharedLib)
+{
+ ELFFile mf(NULL);
+
+ EXPECT_EQ(mf.Open("test-binaries/macos-dll-test1-i386", foRead), osSuccess);
+ // Check architectures.
+ ASSERT_EQ(mf.count(), 1ul);
+ ELFArchitecture &arch = *mf.item(0);
+ // Check exports.
+ IExportList *exp = arch.export_list();
+ EXPECT_EQ(exp->name().compare("@executable_path/hello_lib_cpp.dylib"), 0);
+ ASSERT_EQ(exp->count(), 1ul);
+ EXPECT_EQ(exp->item(0)->name().compare("__ZN13hello_lib_cpp10HelloWorldEPKc"), 0);
+ EXPECT_EQ(exp->item(0)->forwarded_name().compare(""), 0);
+ EXPECT_EQ(exp->item(0)->address(), 0x00000deaull);
+ // Check fixups.
+ IFixupList *fixup_list = arch.fixup_list();
+ ASSERT_EQ(fixup_list->count(), 23ul);
+ EXPECT_EQ(fixup_list->item(0)->address(), 0x00000e84ull);
+ EXPECT_EQ(fixup_list->item(0)->type(), ftHighLow);
+ EXPECT_EQ(fixup_list->item(22)->address(), 0x00001034ull);
+ EXPECT_EQ(fixup_list->item(22)->type(), ftHighLow);
+ mf.Close();
+ EXPECT_EQ(mf.count(), 0ul);
+}*/
+
+TEST(ELFFileTest, Clone)
+{
+ ELFFile mf(NULL);
+
+ ASSERT_EQ(mf.Open("test-binaries/Project1-linux-x64", foRead), osSuccess);
+ ELFFile *f = mf.Clone(mf.file_name().c_str());
+ ASSERT_EQ(mf.count(), f->count());
+ ELFArchitecture &src = *mf.item(0);
+ ELFArchitecture &dst = *f->item(0);
+ EXPECT_EQ(src.owner()->format_name().compare(dst.owner()->format_name()), 0);
+ EXPECT_EQ(src.name().compare(dst.name()), 0);
+ EXPECT_EQ(src.cpu_address_size(), dst.cpu_address_size());
+ EXPECT_EQ(src.entry_point(), dst.entry_point());
+ EXPECT_EQ(src.command_list()->count(), dst.command_list()->count());
+ EXPECT_EQ(src.command_list()->count(), dst.command_list()->count());
+ EXPECT_EQ(src.segment_list()->count(), dst.segment_list()->count());
+ EXPECT_EQ(src.section_list()->count(), dst.section_list()->count());
+ //EXPECT_EQ(src.symbol_list()->count(), dst.symbol_list()->count());
+ EXPECT_EQ(src.import_list()->count(), dst.import_list()->count());
+ EXPECT_EQ(src.fixup_list()->count(), dst.fixup_list()->count());
+ EXPECT_EQ(src.export_list()->count(), dst.export_list()->count());
+ //std::string symbol_name = src.indirect_symbol_list()->item(1)->symbol()->name();
+ //av std::string segment_name = src.section_list()->item(0)->parent()->name();
+ mf.Close();
+ //EXPECT_EQ(dst.indirect_symbol_list()->item(1)->symbol()->name().compare(symbol_name), 0);
+ //av EXPECT_EQ(dst.section_list()->item(0)->parent()->name().compare(segment_name), 0);
+ delete f;
+}
+
+TEST(ELFFileTest, Runtime_x32)
+{
+ ELFFile file(NULL);
+
+ ASSERT_TRUE(file.OpenResource(lin_runtime32_so_file, sizeof(lin_runtime32_so_file), true));
+ ASSERT_EQ(file.count(), 1ul);
+ ELFArchitecture *arch = file.item(0);
+ Buffer buffer(&lin_runtime32_so_code[0]);
+ arch->ReadFromBuffer(buffer);
+ EXPECT_EQ(arch->export_list()->count(), 21ul);
+ EXPECT_GT(arch->function_list()->count(), 0ul);
+}
+
+TEST(ELFFileTest, Runtime_x64)
+{
+ ELFFile file(NULL);
+
+ ASSERT_TRUE(file.OpenResource(lin_runtime64_so_file, sizeof(lin_runtime64_so_file), true));
+ ASSERT_EQ(file.count(), 1ul);
+ ELFArchitecture *arch = file.item(0);
+ Buffer buffer(&lin_runtime64_so_code[0]);
+ arch->ReadFromBuffer(buffer);
+ EXPECT_EQ(arch->export_list()->count(), 21ul);
+ EXPECT_GT(arch->function_list()->count(), 0ul);
+}
+
+#ifdef __unix__
+#ifndef DEMO
+static bool execFile(const std::string &fileName, DWORD &exitCode)
+{
+ exitCode = 0xFFFFFFF;
+ int ret = system(fileName.c_str());
+ if (ret != -1)
+ {
+ exitCode = DWORD(ret);
+ return true;
+ }
+ return false;
+}
+
+/*
+// exc.cpp:
+// clang++ -std=c++11 -target x86_64-linux-gnu -o exc-linux-x64 exc.cpp -L../bin -lVMProtectSDK64 -I ../sdk
+// clang++ -std=c++11 -target i386-linux-gnu -o exc-linux-x86 exc.cpp -L../bin -lVMProtectSDK32 -I ../sdk
+#include <stdio.h>
+#include "VMProtectSDK.h"
+
+__declspec(noinline) void try1()
+{
+ printf("try 1\n");
+ try {
+ throw 1;
+ }
+ catch (int) {
+ printf("catch 1\n");
+ throw;
+ }
+ printf("end 1\n\n");
+}
+
+int main()
+{
+ if (VMProtectIsDebuggerPresent(true))
+ printf("debugger detected\n");
+ if (VMProtectIsVirtualMachinePresent())
+ printf("virtual machine detected\n");
+
+ printf("try main\n");
+ try {
+ try1();
+ }
+ catch (...) {
+ printf("catch main\n");
+ }
+ printf("end main\n");
+
+ return 0;
+}
+*/
+
+TEST(ELFFileTest, EXC_x32)
+{
+ ELFFile pf(NULL);
+ ASSERT_EQ(pf.Open("test-binaries/exc-linux-x86", foRead), osSuccess);
+ ELFArchitecture *arch = pf.item(0);
+ arch->function_list()->AddByAddress(0x08048940, ctVirtualization, 0, true, NULL); // main
+ arch->function_list()->AddByAddress(0x08048890, ctUltra, 0, true, NULL); // try1
+ std::string file_name = pf.file_name() + "_vmp";
+ ELFFile *f = pf.Clone(file_name.c_str());
+ CompileOptions options;
+ options.flags = cpMaximumProtection;
+ options.section_name = ".vmp";
+ ASSERT_TRUE(f->Compile(options));
+ delete f;
+ DWORD ret;
+ ASSERT_TRUE(execFile(file_name, ret));
+ ASSERT_EQ(ret, 0u);
+}
+
+TEST(ELFFileTest, EXC_x64)
+{
+ ELFFile pf(NULL);
+ ASSERT_EQ(pf.Open("test-binaries/exc-linux-x64", foRead), osSuccess);
+ ELFArchitecture *arch = pf.item(0);
+ arch->function_list()->AddByAddress(0x0000000000400B80, ctVirtualization, 0, true, NULL); // main
+ arch->function_list()->AddByAddress(0x0000000000400AE0, ctUltra, 0, true, NULL); // try1
+ std::string file_name = pf.file_name() + "_vmp";
+ ELFFile *f = pf.Clone(file_name.c_str());
+ CompileOptions options;
+ options.flags = cpMaximumProtection;
+ options.section_name = ".vmp";
+ ASSERT_TRUE(f->Compile(options));
+ delete f;
+ DWORD ret;
+ ASSERT_TRUE(execFile(file_name, ret));
+ ASSERT_EQ(ret, 0u);
+}
+#endif // DEMO
+#endif // __unix__ \ No newline at end of file
diff --git a/unit-tests/files_tests.cc b/unit-tests/files_tests.cc
new file mode 100644
index 0000000..7f92789
--- /dev/null
+++ b/unit-tests/files_tests.cc
@@ -0,0 +1,405 @@
+#include "../runtime/crypto.h"
+#include "../core/objects.h"
+#include "../core/osutils.h"
+#include "../core/streams.h"
+#include "../core/files.h"
+#include "../core/processors.h"
+#include "../core/intel.h"
+#include "../core/pefile.h"
+
+#include "testfileintel.h"
+
+TEST(MapFunctionListTest, ReadFromMapFile_Gcc_Test)
+{
+ TestFile test_file(osDWord);
+ TestArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ MapFunctionList *fl = arch.map_function_list();
+ segment_list->Add(0x00401000, 0x000083DC, ".text", mtReadable | mtExecutable);
+ segment_list->Add(0x0040A000, 0x00004A6C, ".data", mtReadable | mtWritable);
+ segment_list->Add(0x0040F000, 0x00002968, ".rdata", mtReadable);
+ segment_list->Add(0x00412000, 0x00000068, ".bss", mtReadable | mtWritable);
+ segment_list->Add(0x00413000, 0x00001AF8, ".idata", mtReadable | mtWritable);
+ segment_list->Add(0x00415000, 0x00000660, "/4", mtDiscardable);
+ segment_list->Add(0x00416000, 0x00001517, "/19", mtDiscardable);
+ segment_list->Add(0x00418000, 0x0007D3B4, "/35", mtDiscardable);
+ segment_list->Add(0x00496000, 0x000055C2, "/47", mtDiscardable);
+ segment_list->Add(0x0049C000, 0x0000518E, "/61", mtDiscardable);
+ segment_list->Add(0x004A2000, 0x000017CC, "/73", mtDiscardable);
+ segment_list->Add(0x004A4000, 0x00003FEB, "/86", mtDiscardable);
+ segment_list->Add(0x004A8000, 0x00007534, "/97", mtDiscardable);
+ segment_list->Add(0x004B0000, 0x00001C78, "/108", mtDiscardable);
+
+ ASSERT_NO_THROW(arch.ReadTestMapFile("test-binaries/gcc-linux-map-1"));
+ ASSERT_EQ(fl->count(), 493ul);
+ EXPECT_EQ(fl->item(0)->name().compare("WinMainCRTStartup"), 0);
+ EXPECT_EQ(fl->item(100)->name().compare("__chkstk"), 0);
+ EXPECT_EQ(fl->item(200)->name().compare("__gnu_cxx::__concurrence_lock_error::~__concurrence_lock_error()"), 0);
+}
+
+TEST(MapFunctionListTest, ReadFromMapFile_Gcc_Test2)
+{
+ TestFile test_file(osQWord);
+ TestArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ MapFunctionList *fl = arch.map_function_list();
+ segment_list->Add(0x0000000008048134, 0x13, ".interp", mtReadable);
+ segment_list->Add(0x0000000008048148, 0x20, ".note.ABI-tag", mtReadable);
+ segment_list->Add(0x0000000008048168, 0x20, ".gnu.hash", mtReadable);
+ segment_list->Add(0x0000000008048188, 0x50, ".dynsym", mtReadable);
+ segment_list->Add(0x00000000080481d8, 0x4a, ".dynstr", mtReadable);
+ segment_list->Add(0x0000000008048222, 0xa, ".gnu.version", mtReadable);
+ segment_list->Add(0x000000000804822c, 0x20, ".gnu.version_r", mtReadable);
+ segment_list->Add(0x000000000804824c, 0x8, ".rel.dyn", mtReadable);
+ segment_list->Add(0x0000000008048254, 0x18, ".rel.plt", mtReadable);
+ segment_list->Add(0x000000000804826c, 0x17, ".init", mtReadable);
+ segment_list->Add(0x0000000008048284, 0x40, ".plt", mtReadable);
+ segment_list->Add(0x00000000080482d0, 0x1a8, ".text", mtReadable | mtExecutable);
+ segment_list->Add(0x0000000008048478, 0x1c, ".fini", mtReadable);
+ segment_list->Add(0x0000000008048494, 0x12, ".rodata", mtReadable);
+ segment_list->Add(0x00000000080484a8, 0x1c, ".eh_frame_hdr", mtReadable);
+ segment_list->Add(0x00000000080484c4, 0x58, ".eh_frame", mtReadable);
+ segment_list->Add(0x000000000804951c, 0x8, ".ctors", mtReadable);
+ segment_list->Add(0x0000000008049524, 0x8, ".dtors", mtReadable);
+ segment_list->Add(0x000000000804952c, 0x4, ".jcr", mtReadable);
+ segment_list->Add(0x0000000008049530, 0xc8, ".dynamic", mtReadable);
+ segment_list->Add(0x00000000080495f8, 0x4, ".got", mtReadable);
+ segment_list->Add(0x00000000080495fc, 0x18, ".got.plt", mtReadable);
+ segment_list->Add(0x0000000008049614, 0x4, ".data", mtReadable);
+ segment_list->Add(0x0000000008049618, 0x8, ".bss", mtReadable);
+
+ ASSERT_NO_THROW(arch.ReadTestMapFile("test-binaries/gcc-linux-map-2"));
+ ASSERT_EQ(fl->count(), 17ul);
+ EXPECT_EQ(fl->item(0)->name().compare("_init"), 0);
+ EXPECT_EQ(fl->item(10)->name().compare("_IO_stdin_used"), 0);
+ EXPECT_EQ(fl->item(16)->name().compare("__data_start"), 0);
+}
+
+TEST(MapFunctionListTest, ReadFromMapFile_GccApple_Test)
+{
+ TestFile test_file(osDWord);
+ TestArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ MapFunctionList *fl = arch.map_function_list();
+ segment_list->Add(0x00000000, 0x00001000, "__PAGEZERO", mtNone);
+ segment_list->Add(0x00001000, 0x00001000, "__TEXT", mtReadable | mtExecutable);
+ segment_list->Add(0x00002000, 0x00001000, "__DATA", mtReadable | mtWritable);
+
+ ASSERT_NO_THROW(arch.ReadTestMapFile("test-binaries/gcc-apple-map"));
+ ASSERT_EQ(fl->count(), 53ul);
+ EXPECT_EQ(fl->item(0)->name().compare("start"), 0);
+ EXPECT_EQ(fl->item(20)->name().compare("_exit"), 0);
+ EXPECT_EQ(fl->item(40)->name().compare("non-lazy-pointer-to: ___gxx_personality_v0"), 0);
+}
+
+TEST(MapFunctionListTest, ReadFromMapFile_Deplhi_Test)
+{
+ TestFile test_file(osDWord);
+ TestArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ MapFunctionList *fl = arch.map_function_list();
+ segment_list->Add(0x00401000, 0x000B9510, ".text", mtReadable | mtExecutable);
+ segment_list->Add(0x004BB000, 0x00000C90, ".itext", mtReadable | mtExecutable);
+ segment_list->Add(0x004BC000, 0x000025B0, ".data", mtReadable | mtWritable);
+ segment_list->Add(0x004BF000, 0x000052E8, ".bss", mtReadable | mtWritable);
+ segment_list->Add(0x004C5000, 0x00003284, ".idata", mtReadable | mtWritable);
+ segment_list->Add(0x004C9000, 0x00000326, ".didata", mtReadable | mtWritable);
+ segment_list->Add(0x004CA000, 0x0000003C, ".tls", mtReadable | mtWritable);
+ segment_list->Add(0x004CB000, 0x00000018, ".rdata", mtReadable);
+ segment_list->Add(0x004CC000, 0x00010AB0, ".reloc", mtReadable | mtDiscardable);
+ segment_list->Add(0x004DD000, 0x0000D000, ".rsrc", mtReadable);
+
+ ASSERT_NO_THROW(arch.ReadTestMapFile("test-binaries/delphi-map"));
+ ASSERT_EQ(fl->count(), 5702ul);
+ EXPECT_EQ(fl->item(0)->name().compare("System..TObject"), 0);
+ EXPECT_EQ(fl->item(1000)->name().compare("SysUtils.DecodeDate"), 0);
+ EXPECT_EQ(fl->item(2000)->name().compare("Classes.TWriter.DefineBinaryProperty"), 0);
+}
+
+TEST(MapFunctionListTest, ReadFromMapFile_Msvc_Test)
+{
+ TestFile test_file(osDWord);
+ TestArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ MapFunctionList *fl = arch.map_function_list();
+ segment_list->Add(0x00401000, 0x00023FC9, ".textbss", mtReadable | mtWritable | mtExecutable);
+ segment_list->Add(0x00425000, 0x0004BD1F, ".text", mtReadable | mtExecutable);
+ segment_list->Add(0x00471000, 0x0000EF7A, ".rdata", mtReadable);
+ segment_list->Add(0x00480000, 0x00003898, ".data", mtReadable | mtExecutable);
+ segment_list->Add(0x00484000, 0x00000D35, ".idata", mtReadable | mtExecutable);
+ segment_list->Add(0x00485000, 0x000005C0, ".rsrc", mtReadable);
+ segment_list->Add(0x00486000, 0x000035D3, ".reloc", mtReadable);
+
+ ASSERT_NO_THROW(arch.ReadTestMapFile("test-binaries/msvc-map"));
+ ASSERT_EQ(fl->count(), 2055ul);
+ EXPECT_EQ(fl->item(0)->name().compare("__enc$textbss$begin"), 0);
+ EXPECT_EQ(fl->item(1000)->name().compare("`string'"), 0);
+ EXPECT_EQ(fl->item(2000)->name().compare("__imp__TlsGetValue@4"), 0);
+ // Check static symbol
+ ASSERT_TRUE(fl->GetFunctionByName("char * UnDecorator::outputString") != NULL);
+}
+
+TEST(MapFunctionListTest, ReadFromMapFile_Msvc_Test2)
+{
+ TestFile test_file(osQWord);
+ TestArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ MapFunctionList *fl = arch.map_function_list();
+ segment_list->Add(0x00401000, 0x00042578, ".text", mtReadable | mtExecutable);
+ segment_list->Add(0x00444000, 0x0000C4F6, ".rdata", mtReadable);
+ segment_list->Add(0x00451000, 0x00000B08, ".data", mtReadable | mtWritable);
+ segment_list->Add(0x00452000, 0x00001788, ".pdata", mtReadable);
+ segment_list->Add(0x00454000, 0x00002003, ".idata", mtReadable | mtWritable);
+ segment_list->Add(0x00457000, 0x00000C09, ".rsrc", mtReadable);
+
+ ASSERT_NO_THROW(arch.ReadTestMapFile("test-binaries/msvc-x64-map-2"));
+ ASSERT_EQ(fl->count(), 732ul);
+ EXPECT_EQ(fl->item(0)->name().compare("test_header(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"), 0);
+ EXPECT_EQ(fl->item(300)->name().compare("isxdigit"), 0);
+ EXPECT_EQ(fl->item(600)->name().compare("__imp_UnhandledExceptionFilter"), 0);
+}
+
+TEST(MapFunctionListTest, Map_Test)
+{
+ TestFile test_file(osQWord);
+ TestArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ MapFunctionList *fl = arch.map_function_list();
+ MapFunction *mf = NULL;
+ segment_list->Add(0x00401000, 0x00042578, ".text", mtReadable | mtExecutable);
+ segment_list->Add(0x00444000, 0x0000C4F6, ".rdata", mtReadable);
+ segment_list->Add(0x00451000, 0x00000B08, ".data", mtReadable | mtWritable);
+ segment_list->Add(0x00452000, 0x00001788, ".pdata", mtReadable);
+ segment_list->Add(0x00454000, 0x00002003, ".idata", mtReadable | mtWritable);
+ segment_list->Add(0x00457000, 0x00000C09, ".rsrc", mtReadable);
+
+ ASSERT_NO_THROW(arch.ReadTestMapFile("test-binaries/msvc-x64-map-2"));
+ ASSERT_NO_THROW(mf = fl->GetFunctionByName("main"));
+ ASSERT_TRUE(mf != NULL);
+ EXPECT_EQ(mf->name().compare("main"), 0);
+ EXPECT_EQ(mf->address(), 0x402ef0ull);
+ ASSERT_NO_THROW(mf = fl->GetFunctionByAddress(0x40b460));
+ ASSERT_TRUE(mf != NULL);
+ EXPECT_EQ(mf->name().compare("pcre_exec"), 0);
+ EXPECT_EQ(mf->address(), 0x40b460ull);
+}
+
+TEST(MemoryManager, Alloc)
+{
+ MemoryManager manager(NULL);
+
+ manager.Add(0x1000, 0x1000, mtReadable, NULL);
+ manager.Add(0x2000, 0x300, mtReadable | mtExecutable, NULL);
+ manager.Add(0x3000, 0x100, mtReadable | mtWritable, NULL);
+ EXPECT_EQ(manager.Alloc(0x10, mtReadable | mtExecutable), 0x2000ull);
+ EXPECT_EQ(manager.Alloc(0x10, mtReadable | mtExecutable), 0x2010ull);
+ EXPECT_EQ(manager.Alloc(0x10, mtReadable | mtExecutable, 0, 0x200), 0x2200ull);
+ EXPECT_EQ(manager.Alloc(0x20, mtReadable | mtWritable), 0x3000ull);
+ EXPECT_EQ(manager.Alloc(0x20, mtReadable | mtWritable), 0x3020ull);
+ EXPECT_EQ(manager.Alloc(0x200, mtNone, 0x1800), 0x1800ull);
+ EXPECT_EQ(manager.Alloc(0x20, mtReadable | mtExecutable, 0x1900), 0ull);
+ EXPECT_EQ(manager.count(), 5ul);
+}
+
+TEST(MemoryManager, Remove)
+{
+ MemoryManager manager(NULL);
+
+ manager.Add(7, 3, mtReadable, NULL);
+ manager.Add(1, 5, mtReadable, NULL);
+ ASSERT_NO_THROW(manager.Remove(4, 4));
+ ASSERT_EQ(manager.count(), 2ul);
+ EXPECT_EQ(manager.item(0)->address(), 1ull);
+ EXPECT_EQ(manager.item(0)->end_address(), 4ull);
+ EXPECT_EQ(manager.item(1)->address(), 8ull);
+ EXPECT_EQ(manager.item(1)->end_address(), 10ull);
+
+ ASSERT_NO_THROW(manager.Remove(8, 2));
+ ASSERT_EQ(manager.count(), 1ul);
+}
+
+TEST(MemoryManager, Pack)
+{
+ MemoryManager manager(NULL);
+
+ manager.Add(0x1000, 0x1000, mtReadable | mtExecutable, NULL);
+ manager.Add(0x2000, 0x100, mtReadable | mtExecutable, NULL);
+ manager.Add(0x2100, 0x100, mtReadable, NULL);
+ manager.Pack();
+ ASSERT_EQ(manager.count(), 2ul);
+ MemoryRegion *region = manager.item(0);
+ EXPECT_EQ(region->address(), 0x1000ull);
+ EXPECT_EQ(region->end_address(), 0x2100ull);
+ EXPECT_EQ((int)region->type(), (mtReadable | mtExecutable));
+ region = manager.item(1);
+ EXPECT_EQ(region->address(), 0x2100ull);
+ EXPECT_EQ(region->end_address(), 0x2200ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+}
+
+TEST(MemoryManager, SimpleRemove)
+{
+ MemoryManager manager(NULL);
+
+ manager.Add(1, 4, mtReadable, NULL);
+ manager.Add(7, 3, mtReadable, NULL);
+ manager.Remove(4, 4);
+
+ ASSERT_EQ(manager.count(), 2ul);
+ MemoryRegion *region = manager.item(0);
+ EXPECT_EQ(region->address(), 1ull);
+ EXPECT_EQ(region->end_address(), 4ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(1);
+ EXPECT_EQ(region->address(), 8ull);
+ EXPECT_EQ(region->end_address(), 10ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+
+ manager.Remove(30, 30);
+
+ ASSERT_EQ(manager.count(), 2ul);
+ region = manager.item(0);
+ EXPECT_EQ(region->address(), 1ull);
+ EXPECT_EQ(region->end_address(), 4ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(1);
+ EXPECT_EQ(region->address(), 8ull);
+ EXPECT_EQ(region->end_address(), 10ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+
+ manager.Remove(9, 30);
+
+ ASSERT_EQ(manager.count(), 2ul);
+ region = manager.item(0);
+ EXPECT_EQ(region->address(), 1ull);
+ EXPECT_EQ(region->end_address(), 4ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(1);
+ EXPECT_EQ(region->address(), 8ull);
+ EXPECT_EQ(region->end_address(), 9ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+
+ manager.Remove(3, 1);
+
+ ASSERT_EQ(manager.count(), 2ul);
+ region = manager.item(0);
+ EXPECT_EQ(region->address(), 1ull);
+ EXPECT_EQ(region->end_address(), 3ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(1);
+ EXPECT_EQ(region->address(), 8ull);
+ EXPECT_EQ(region->end_address(), 9ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+
+ manager.Remove(0, 15);
+
+ ASSERT_EQ(manager.count(), 0ul);
+}
+
+TEST(MemoryManager, ExtendedRemove)
+{
+ MemoryManager manager(NULL);
+
+ manager.Add(1, 4, mtReadable, NULL);
+ manager.Add(7, 3, mtReadable, NULL);
+ manager.Add(15, 5, mtReadable, NULL);
+ manager.Remove(2, 1);
+
+ ASSERT_EQ(manager.count(), 4ul);
+ MemoryRegion *region = manager.item(0);
+ EXPECT_EQ(region->address(), 1ull);
+ EXPECT_EQ(region->end_address(), 2ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(1);
+ EXPECT_EQ(region->address(), 3ull);
+ EXPECT_EQ(region->end_address(), 5ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(2);
+ EXPECT_EQ(region->address(), 7ull);
+ EXPECT_EQ(region->end_address(), 10ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(3);
+ EXPECT_EQ(region->address(), 15ull);
+ EXPECT_EQ(region->end_address(), 20ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+
+ manager.Remove(8, 1);
+ ASSERT_EQ(manager.count(), 5ul);
+ region = manager.item(0);
+ EXPECT_EQ(region->address(), 1ull);
+ EXPECT_EQ(region->end_address(), 2ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(1);
+ EXPECT_EQ(region->address(), 3ull);
+ EXPECT_EQ(region->end_address(), 5ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(2);
+ EXPECT_EQ(region->address(), 7ull);
+ EXPECT_EQ(region->end_address(), 8ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(3);
+ EXPECT_EQ(region->address(), 9ull);
+ EXPECT_EQ(region->end_address(), 10ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(4);
+ EXPECT_EQ(region->address(), 15ull);
+ EXPECT_EQ(region->end_address(), 20ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+
+ manager.Remove(16, 1);
+ ASSERT_EQ(manager.count(), 6ul);
+ region = manager.item(0);
+ EXPECT_EQ(region->address(), 1ull);
+ EXPECT_EQ(region->end_address(), 2ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(1);
+ EXPECT_EQ(region->address(), 3ull);
+ EXPECT_EQ(region->end_address(), 5ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(2);
+ EXPECT_EQ(region->address(), 7ull);
+ EXPECT_EQ(region->end_address(), 8ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(3);
+ EXPECT_EQ(region->address(), 9ull);
+ EXPECT_EQ(region->end_address(), 10ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(4);
+ EXPECT_EQ(region->address(), 15ull);
+ EXPECT_EQ(region->end_address(), 16ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(5);
+ EXPECT_EQ(region->address(), 17ull);
+ EXPECT_EQ(region->end_address(), 20ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+
+ manager.Remove(6, 5);
+ ASSERT_EQ(manager.count(), 4ul);
+ region = manager.item(0);
+ EXPECT_EQ(region->address(), 1ull);
+ EXPECT_EQ(region->end_address(), 2ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(1);
+ EXPECT_EQ(region->address(), 3ull);
+ EXPECT_EQ(region->end_address(), 5ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(2);
+ EXPECT_EQ(region->address(), 15ull);
+ EXPECT_EQ(region->end_address(), 16ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(3);
+ EXPECT_EQ(region->address(), 17ull);
+ EXPECT_EQ(region->end_address(), 20ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+
+ manager.Remove(15, 100);
+ ASSERT_EQ(manager.count(), 2ul);
+ region = manager.item(0);
+ EXPECT_EQ(region->address(), 1ull);
+ EXPECT_EQ(region->end_address(), 2ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+ region = manager.item(1);
+ EXPECT_EQ(region->address(), 3ull);
+ EXPECT_EQ(region->end_address(), 5ull);
+ EXPECT_EQ((int)region->type(), mtReadable);
+} \ No newline at end of file
diff --git a/unit-tests/il_tests.cc b/unit-tests/il_tests.cc
new file mode 100644
index 0000000..41e8bc1
--- /dev/null
+++ b/unit-tests/il_tests.cc
@@ -0,0 +1,90 @@
+#include "../runtime/crypto.h"
+#include "../core/objects.h"
+#include "../core/osutils.h"
+#include "../core/streams.h"
+#include "../core/core.h"
+#include "../core/files.h"
+#include "../core/processors.h"
+#include "../core/pefile.h"
+#include "../core/il.h"
+#include "../core/dotnetfile.h"
+
+#include "testfileil.h"
+
+TEST(ILTest, DisasmSmoke)
+{
+ uint8_t buf[] = {
+ /*
+ .method public hidebysig static bool TakesSingleByteArgument(valuetype System.Reflection.Emit.OpCode inst) cil managed
+ SIG: 00 01 02 11 92 88
+ {
+ // Method begins at RVA 0x94b60
+ // Code size 45 (0x2D)
+ .maxstack 2
+ .locals init (valuetype System.Reflection.Emit.OperandType V_0)
+ */
+ 0x2D * 4 + 2, // Tiny header
+ 0x0F, 0x00, // IL_0000: ldarga.s inst
+ 0x7B, 0x04, 0x00, 0x16, 0xF8, // IL_0002: ldfld valuetype System.Reflection.Emit.OperandType System.Reflection.Emit.OpCode::m_operand
+ 0x0A, // IL_0007: stloc.0
+ 0x06, // IL_0008: ldloc.0
+ 0x1F, 0x0F, // IL_0009: ldc.i4.s 15
+ 0x59, // IL_000b: sub
+ 0x45, 0x04, 0x00, 0x00, 0x00, // IL_000c: switch (
+ 0x02, 0x00, 0x00, 0x00, // IL_0023,
+ 0x02, 0x00, 0x00, 0x00, // IL_0023,
+ 0x04, 0x00, 0x00, 0x00, // IL_0025,
+ 0x02, 0x00, 0x00, 0x00, // IL_0023)
+ 0x2B, 0x02, // IL_0021: br.s IL_0025
+ 0x17, // IL_0023: ldc.i4.1
+ 0x2A, // IL_0024: ret
+ 0x16, // IL_0025: ldc.i4.0
+ 0xFE, 0x13, // IL_0026: volatile.?
+ 0x2A, // IL_0027: ret
+ //} end of method OpCodes::TakesSingleByteArgument
+ };
+
+ //ILFunction *func;
+ //MapFunctionList *map_function_list;
+ //MapFunction *map_function;
+ //ILCommand *command;
+
+ /*
+ TestFile test_file(osDWord);
+ TestArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = arch.segment_list();
+ uint64_t addr = 0x004B58EC;
+ TestSegment *segment = segment_list->Add(addr, 0x10000, ".text", mtReadable | mtExecutable);
+
+ segment->set_physical_size(sizeof(buf));
+ test_file.OpenFromMemory(buf, sizeof(buf));
+ arch.runtime_function_list()->AddObject(
+ new NETRuntimeFunction(arch.runtime_function_list(), addr, addr + (buf[0] >> 2) + 1, addr + 1, NULL, NULL));
+ func = reinterpret_cast<ILFunction *>(arch.function_list()->AddByAddress(addr + 1, ctVirtualization, 0, true, NULL));
+ ASSERT_EQ(func->count(), 13ul);
+ */
+/*
+ map_function_list = arch.map_function_list();
+ map_function = map_function_list->GetFunctionByName("VMProtectMarker1");
+ ASSERT_TRUE(map_function != NULL);
+ EXPECT_EQ(map_function->address(), 0x004B5906ull);
+ EXPECT_EQ(func->ReadFromFile(arch, map_function->address()), 45ul);
+ // Check CompileToNative
+ std::vector<uint8_t> data;
+ size_t i, j;
+ for (i = 0; i < func->count(); i++) {
+ command = func->item(i);
+ if ((command->type() == cmJmpWithFlag || command->type() == cmJmp || command->type() == cmCall) && command->dump_size() == 2)
+ continue;
+
+ data.clear();
+ for (j = 0; j < command->dump_size(); j++) {
+ data.push_back(command->dump(j));
+ }
+ command->CompileToNative();
+ EXPECT_EQ(command->dump_size(), data.size());
+ for (j = 0; j < command->dump_size(); j++) {
+ EXPECT_EQ(command->dump(j), data[j]);
+ }
+ }*/
+}
diff --git a/unit-tests/intel_tests.cc b/unit-tests/intel_tests.cc
new file mode 100644
index 0000000..6ea3fb5
--- /dev/null
+++ b/unit-tests/intel_tests.cc
@@ -0,0 +1,4493 @@
+#include "../runtime/crypto.h"
+#include "../core/objects.h"
+#include "../core/osutils.h"
+#include "../core/streams.h"
+#include "../core/core.h"
+#include "../core/files.h"
+#include "../core/processors.h"
+#include "../core/pefile.h"
+#include "../core/intel.h"
+
+#include "testfileintel.h"
+
+TEST(IntelTest, x86_AsmMarkers)
+{
+ uint8_t buf[] = {
+ 0x55, // 004B58EC push ebp
+ 0x8B, 0xEC, // 004B58ED mov ebp, esp
+ 0x6A, 0x00, // 004B58EF push 00
+ 0x6A, 0x00, // 004B58F1 push 00
+ 0x6A, 0x00, // 004B58F3 push 00
+ 0x53, // 004B58F5 push ebx
+ 0x8B, 0xD8, // 004B58F6 mov ebx, eax
+ 0x33, 0xC0, // 004B58F8 xor eax, eax
+ 0x55, // 004B58FA push ebp
+ 0x68, 0xDA, 0x59, 0x4B, 0x00, // 004B58FB push 004B59DA
+ 0x64, 0xFF, 0x30, // 004B5900 push dword ptr fs:[eax]
+ 0x64, 0x89, 0x20, // 004B5903 mov fs:[eax], esp
+ 0xEB, 0x10, // 004B5906 jmp 004B5918
+ 0x56, 0x4D, 0x50, 0x72, 0x6F, 0x74, 0x65, 0x63, 0x74, 0x20, 0x62, 0x65, 0x67, 0x69, 0x6E, 0x00, // db 'VMProtect begin', 0
+ 0x8D, 0x55, 0xFC, // 004B5918 lea edx, [ebp-04]
+ 0x8B, 0x83,
+ 0x8C, 0x03, 0x00, 0x00, // 004B591A mov eax, [ebx+0000038C]
+ 0xE8, 0x0A, 0xE0, 0xFC, 0xFF, // 004B5920 call 00483930
+ 0x8B, 0x45, 0xFC, // 004B5925 mov eax, [ebp-04]
+ 0x33, 0xD2, // 004B5928 xor edx, edx
+ 0xE8, 0xD4, 0xCB, 0xF5, 0xFF, // 004B592A call 00412504
+ 0xB9, 0x11, 0x00, 0x00, 0x00, // 004B592F mov ecx, 00000011
+ 0x99, // 004B5930 cdq
+ 0xF7, 0xF9, // 004B5931 idiv ecx
+ 0x83, 0xFA, 0x0D, // 004B5933 cmp edx, 0D
+ 0x75, 0x2F, // 004B5936 jnz 004B596C
+ 0x68, 0xE8, 0x59, 0x4B, 0x00, // 004B5938 push 004B59E8
+ 0xE8, 0x81, 0xFC, 0xFF, 0xFF, // 004B593D call 004B55C8
+ 0x8B, 0xD0, // 004B5942 mov edx, eax
+ 0x8D, 0x45, 0xF8, // 004B5944 lea eax, [ebp-08]
+ 0xE8, 0x6F, 0x10, 0xF5, 0xFF, // 004B5947 call 004069C0
+ 0x8B, 0x45, 0xF8, // 004B594C mov eax, [ebp-08]
+ 0x6A, 0x00, // 004B594F push 00
+ 0x6A, 0xFF, // 004B5951 push -01
+ 0x6A, 0xFF, // 004B5953 push -01
+ 0x6A, 0x00, // 004B5955 push 00
+ 0x0F, 0xB7, 0x0D,
+ 0xFC, 0x59, 0x4B, 0x00, // 004B5957 movzx ecx, word ptr [004B59FC]
+ 0xB2, 0x02, // 004B595E mov dl, 02
+ 0xE8, 0xAA, 0x4A, 0xFB, 0xFF, // 004B5960 call 0046A414
+ 0xEB, 0x4B, // 004B5965 jmp 004B59B7
+ 0x68, 0x00, 0x5A, 0x4B, 0x00, // 004B5967 push 004B5A00
+ 0xE8, 0x52, 0xFC, 0xFF, 0xFF, // 004B596C call 004B55C8
+ 0x8B, 0xD0, // 004B5971 mov edx, eax
+ 0x8D, 0x45, 0xF4, // 004B5973 lea eax, [ebp-0C]
+ 0xE8, 0x40, 0x10, 0xF5, 0xFF, // 004B5976 call 004069C0
+ 0x8B, 0x45, 0xF4, // 004B597B mov eax, [ebp-0C]
+ 0x6A, 0x00, // 004B597E push 00
+ 0x6A, 0xFF, // 004B5980 push -01
+ 0x6A, 0xFF, // 004B5982 push -01
+ 0x6A, 0x00, // 004B5984 push 00
+ 0x0F, 0xB7, 0x0D,
+ 0xFC, 0x59, 0x4B, 0x00, // 004B5986 movzx ecx, word ptr [004B59FC]
+ 0xB2, 0x01, // 004B598D mov dl, 01
+ 0xE8, 0x7B, 0x4A, 0xFB, 0xFF, // 004B598F call 0046A414
+ 0x8B, 0x83,
+ 0x8C, 0x03, 0x00, 0x00, // 004B5994 mov eax, [ebx+0000038C]
+ 0x8B, 0x10, // 004B599A mov edx, [eax]
+ 0xFF, 0x92,
+ 0xE8, 0x00, 0x00, 0x00, // 004B599C call dword ptr [edx+000000E8]
+ 0xEB, 0x0E, // 004B59A2 jmp 004B59B7
+ 0x56, 0x4D, 0x50, 0x72, 0x6F, 0x74, 0x65, 0x63, 0x74, 0x20, 0x65, 0x6E, 0x64, 0x00, // db 'VMProtect end', 00
+ 0x33, 0xC0, // 004B59B2 xor eax, eax
+ 0x5A, // 004B59B4 pop edx
+ 0x59, // 004B59B5 pop ecx
+ 0x59, // 004B59B6 pop ecx
+ 0x64, 0x89, 0x10, // 004B59B7 mov fs:[eax], edx
+ 0x68, 0xE1, 0x59, 0x4B, 0x00, // 004B59BA push 004B59E1
+ 0x8D, 0x45, 0xF4, // 004B59BF lea eax, [ebp-0C]
+ 0xBA, 0x02, 0x00, 0x00, 0x00, // 004B59C2 mov edx, 00000002
+ 0xE8, 0x6B, 0x0E, 0xF5, 0xFF, // 004B59C7 call 0040683C
+ 0x8D, 0x45, 0xFC, // 004B59CC lea eax, [ebp-04]
+ 0xE8, 0x5B, 0x0E, 0xF5, 0xFF, // 004B59CF call 00406834
+ 0xC3, // 004B59D4 ret
+ 0xE9, 0xC1, 0xFD, 0xF4, 0xFF, // 004B59D5 jmp 004057A0
+ 0xEB, 0xE3, // 004B59DA jmp 004B59C4
+ 0x5B, // 004B59DC pop ebx
+ 0x8B, 0xE5, // 004B59DD mov esp, ebp
+ 0x5D, // 004B59DF pop ebp
+ 0xC3, // 004B59E0 ret
+ 0x90, 0x90, 0x90, 0x90
+ };
+
+ IntelFunction *func;
+ MapFunctionList *map_function_list;
+ MapFunction *map_function;
+ IntelCommand *command;
+
+ TestFile test_file(osDWord);
+ TestArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ TestSegment *segment = segment_list->Add(0x004B58EC, 0x10000, ".text", mtReadable | mtExecutable);
+ segment->set_physical_size(sizeof(buf));
+ test_file.OpenFromMemory(buf, sizeof(buf));
+ func = reinterpret_cast<IntelFunction *>(arch.function_list()->AddByAddress(segment_list->item(0)->address(), ctVirtualization, 0, true, NULL));
+ ASSERT_EQ(func->count(), 73ul);
+ map_function_list = arch.map_function_list();
+ map_function = map_function_list->GetFunctionByName("VMProtectMarker1");
+ ASSERT_TRUE(map_function != NULL);
+ EXPECT_EQ(map_function->address(), 0x004B5906ull);
+ EXPECT_EQ(func->ReadFromFile(arch, map_function->address()), 45ul);
+ // Check CompileToNative
+ std::vector<uint8_t> data;
+ size_t i, j;
+ for (i = 0; i < func->count(); i++) {
+ command = func->item(i);
+ if ((command->type() == cmJmpWithFlag || command->type() == cmJmp || command->type() == cmCall) && command->dump_size() == 2)
+ continue;
+
+ data.clear();
+ for (j = 0; j < command->dump_size(); j++) {
+ data.push_back(command->dump(j));
+ }
+ command->CompileToNative();
+ EXPECT_EQ(command->dump_size(), data.size());
+ for (j = 0; j < command->dump_size(); j++) {
+ EXPECT_EQ(command->dump(j), data[j]);
+ }
+ }
+}
+
+TEST(IntelTest, CompilerFunction_Delphi)
+{
+ PEFile pf(NULL);
+
+ EXPECT_EQ(pf.Open("test-binaries/win32-app-delphi-i386", foRead), osSuccess);
+ EXPECT_EQ(pf.count(), 1ul);
+ PEArchitecture &arch = *pf.arch_pe();
+ IntelFunction command_list;
+ EXPECT_EQ(command_list.ReadFromFile(arch, 0x004BBC48), 17ul);
+ EXPECT_EQ(command_list.ReadFromFile(arch, 0x004B5A34), 2ul);
+}
+
+uint8_t char2hex(char d)
+{
+ if ((d >= '0') && (d <= '9')) {
+ return (d - '0');
+ }
+ if ((d >= 'A') && (d <= 'F')) {
+ return (d - '7');
+ }
+ if ((d >= 'a') && (d <= 'f')) {
+ return (d - 'W');
+ }
+ return 0;
+}
+
+void ascii2hex(const char *inp, uint8_t *out, size_t size)
+{
+ size_t i, j;
+
+ for (i=0, j=0; j<size/2; j++, i+=2) {
+ out[j] = (char2hex(inp[i]) << 4) + char2hex(inp[i+1]);
+ }
+}
+
+TEST(IntelTest, x86)
+{
+// TestFile test_file(osDWord);
+ TestFile test_file(osQWord);
+ IArchitecture &arch = *test_file.item(0);
+
+ IntelCommand intel_command(NULL, arch.cpu_address_size(), 0x401000);
+ size_t i, k, n;
+ FileStream fs;
+ bool status;
+ std::string line, udisstr, intel_str;
+ uint8_t dump[40], sse_preffix;
+
+ return;
+
+ status = fs.Open("test-binaries/intel-x64-opcodes.txt", fmOpenRead | fmShareDenyNone); //-V779
+
+ ASSERT_TRUE(status);
+ for (;;) {
+ if (!fs.ReadLine(line))
+ break;
+ i = line.find(' ');
+ if (i > 0) {
+ ascii2hex(line.c_str(), dump, i);
+
+ n = 0;
+ sse_preffix = 0;
+ for (k = 0; k < i/2; k++) {
+ if (dump[k] == 0xF2 || dump[k] == 0xF3 || (dump[k] == 0x66 && sse_preffix == 0))
+ sse_preffix = dump[k];
+ if (dump[k] == 0x26 ||
+ dump[k] == 0x2e ||
+ dump[k] == 0x36 ||
+ dump[k] == 0x3e ||
+ dump[k] == 0x64 ||
+ dump[k] == 0x65 ||
+ dump[k] == 0x66 ||
+ dump[k] == 0x67 ||
+ dump[k] == 0xF2 ||
+ dump[k] == 0xF3
+ ) {
+ n++;
+ } else {
+ break;
+ }
+ }
+
+ // VMRUN is not decoded by udis when ud_set_vendor(&u, UD_VENDOR_INTEL) is called; not a bug
+ if (dump[n] == 0x0f && dump[n+1] == 0x01 && dump[n+2] >= 0xc0)
+ continue;
+
+ // Workarounds for UDIS bugs (low priority of fixing)
+ // UDIS workaround: mov invalid_CR, reg, mov reg, invalid_CR
+ if (dump[n] == 0x0f && (dump[n+1] == 0x20 || dump[n + 1] == 0x22)) {
+ unsigned cr = (dump[n+2] & 0x38) >> 3;
+ if (cr == 1 || (cr >= 5 && cr <= 7) || cr >= 9)
+ continue;
+ }
+
+ if (arch.cpu_address_size() == osQWord) {
+ if ((dump[n] >= 0x48 && dump[n] <= 0x4f && dump[n+1] == 0x6d)
+ || (dump[n] == 0x48 && dump[n+1] == 0x6f)
+ || (dump[n] == 0x9c)
+ || (dump[n] == 0x9d)
+ )
+ continue;
+ }
+
+ //dprint((line.c_str()));
+ //dprint(("\n"));
+
+ test_file.OpenFromMemory(dump, (uint32_t)(i / 2));
+ udisstr = line.substr(i + 1);
+ try {
+ if (intel_command.ReadFromFile(arch) != i / 2) {
+ if (intel_command.type() == cmDB && (line.substr(i + 1, 2).compare("db") == 0 || udisstr.find("invalid") != udisstr.npos))
+ continue;
+
+ FAIL() << "Cannot disassemble:\nudis: '" << udisstr
+ << "'\nintel_command: '" << intel_command.text() << "'\n" <<
+ "binary: " << line.substr(0, i);
+ }
+ } catch (std::runtime_error & e) {
+ FAIL() << "Exception '" << e.what() << "'\n" << "Input: " << line;
+ }
+ intel_str = intel_command.text();
+ std::transform(intel_str.begin(), intel_str.end(), intel_str.begin(), ::tolower);
+ if (intel_str.compare(udisstr) != 0) {
+ if (udisstr.find("invalid") != udisstr.npos && intel_command.type() == cmDB)
+ continue;
+
+ if (udisstr.find("rip+") != udisstr.npos) {
+ //dprint((line.c_str()));
+ //dprint(("\n"));
+ continue;
+ }
+
+ if (intel_command.type() == cmLoop ||
+ intel_command.type() == cmLoope ||
+ intel_command.type() == cmLoopne ||
+ intel_command.type() == cmJCXZ ||
+ intel_command.type() == cmJmp ||
+ intel_command.type() == cmCall ||
+ intel_command.type() == cmPusha ||
+ intel_command.type() == cmPopa ||
+ intel_command.type() == cmJmpWithFlag)
+ continue;
+ FAIL() << "Disasm error:\nudis: '" << udisstr
+ << "'\nintel_command: '" << intel_str << "'\n" <<
+ "binary: " << line.substr(0, i);
+ }
+ }
+ }
+};
+
+TEST(IntelTest, x86_Disasm)
+{
+ PEFile pf(NULL);
+ IntelFunction command_list;
+
+ EXPECT_EQ(pf.Open("test-binaries/win32-app-test1-i386", foRead), osSuccess);
+ EXPECT_EQ(pf.count(), 1ul);
+ IArchitecture &arch = *pf.item(0);
+ EXPECT_EQ(command_list.ReadFromFile(arch, 0x00401198), 53ul);
+ EXPECT_TRUE(command_list.GetCommandByNearAddress(0x00401235) != NULL);
+ EXPECT_EQ(command_list.item(0)->address(), 0x00401198ull);
+ EXPECT_EQ(command_list.item(command_list.count() - 1)->next_address(), 0x00401240ull);
+}
+
+TEST(IntelTest, x86_DelphiSEH)
+{
+ uint8_t buf[] = {
+ 0x55, // push ebp
+ 0x8B, 0xEC, // mov ebp, esp
+ 0x83, 0xC4, 0xEC, // add esp, -14
+ 0x53, // push ebx
+ 0x56, // push esi
+ 0x57, // push edi
+ 0x33, 0xC0, // xor eax, eax
+ 0x89, 0x45, 0xEC, // mov [ebp-14], eax
+ 0xA1, 0x9C, 0x1D, 0x41, 0x00, // mov eax, [00411D9C]
+ 0xC6, 0x00, 0x01, // mov byte ptr [eax], 01
+ 0xB8, 0xB4, 0xE4, 0x40, 0x00, // mov eax, 0040E4B4
+ 0xE8, 0x10, 0x89, 0xFF, 0xFF, // call 00408AA0
+ 0x33, 0xC0, // xor eax, eax
+ 0x55, // push ebp
+ 0x68, 0x37, 0x02, 0x41, 0x00, // push 00410237
+ 0x64, 0xFF, 0x30, // push dword ptr fs:[eax]
+ 0x64, 0x89, 0x20, // mov fs:[eax], esp
+ 0x33, 0xC0, // xor eax, eax
+ 0x55, // push ebp
+ 0x68, 0xD6, 0x01, 0x41, 0x00, // push 004101D6
+ 0x64, 0xFF, 0x30, // push dword ptr fs:[eax]
+ 0x64, 0x89, 0x20, // mov fs:[eax], esp
+ 0xB8, 0x32, 0x00, 0x00, 0x00, // mov eax, 00000032
+ 0xE8, 0x06, 0x3B, 0xFF, 0xFF, // call 00403CBC
+ 0x8B, 0xD0, // mov edx, eax
+ 0xA1, 0xE0, 0x1C, 0x41, 0x00, // mov eax, [00411CE0]
+ 0xE8, 0x72, 0x42, 0xFF, 0xFF, // call 00404434
+ 0xE8, 0x99, 0x42, 0xFF, 0xFF, // call 00404460
+ 0xE8, 0xA0, 0x39, 0xFF, 0xFF, // call 00403B6C
+ 0x33, 0xC0, // xor eax, eax
+ 0x5A, // pop edx
+ 0x59, // pop ecx
+ 0x59, // pop ecx
+ 0x64, 0x89, 0x10, // mov fs:[eax], edx
+ 0xEB, 0x4B, // jmp 00410221
+ 0xE9, 0x21, 0x4F, 0xFF, 0xFF, // jmp 004050FC
+ 0x01, 0x00, 0x00, 0x00, // dd 00000001
+ 0x54, 0x90, 0x41, 0x00, // dd 00419054
+ 0xE7, 0x01, 0x41, 0x00, // dd 004101E7
+ 0x8B, 0xD8, // mov ebx, eax
+ 0x8D, 0x55, 0xEC, // lea edx, [ebp-14]
+ 0x8B, 0x03, // mov eax, [ebx]
+ 0xE8, 0xBD, 0x45, 0xFF, 0xFF, // call 004047B0
+ 0x8B, 0x55, 0xEC, // mov edx, [ebp-14]
+ 0xA1, 0xE0, 0x1C, 0x41, 0x00, // mov eax, [00411CE0]
+ 0xE8, 0x8C, 0x64, 0xFF, 0xFF, // call 0040668C
+ 0xBA, 0x54, 0x02, 0x41, 0x00, // mov edx, 00410254
+ 0xE8, 0x82, 0x64, 0xFF, 0xFF, // call 0040668C
+ 0x8B, 0x53, 0x04, // mov edx, [ebx+04]
+ 0xE8, 0x7A, 0x64, 0xFF, 0xFF, // call 0040668C
+ 0xE8, 0x49, 0x42, 0xFF, 0xFF, // call 00404460
+ 0xE8, 0x50, 0x39, 0xFF, 0xFF, // call 00403B6C
+ 0xE8, 0x07, 0x52, 0xFF, 0xFF, // call 00405428
+ 0x33, 0xC0, // xor eax, eax
+ 0x5A, // pop edx
+ 0x59, // pop ecx
+ 0x59, // pop ecx
+ 0x64, 0x89, 0x10, // mov fs:[eax], edx
+ 0x68, 0x3E, 0x02, 0x41, 0x00, // push 0041023E
+ 0x8D, 0x45, 0xEC, // lea eax, [ebp-14]
+ 0xE8, 0x66, 0x5E, 0xFF, 0xFF, // call 0040609C
+ 0xC3, // ret
+ 0xE9, 0x48, 0x50, 0xFF, 0xFF, // jmp 00405284
+ 0xEB, 0xF0, // jmp 0041022E
+ 0x5F, // pop edi
+ 0x5E, // pop esi
+ 0x5B, // pop ebx
+ 0xE8, 0xF6, 0x56, 0xFF, 0xFF, // call 0040593C
+ 0xC3 // ret
+ };
+
+ ICommand *command;
+ IntelFunction *func;
+ TestFile test_file(osDWord);
+ IArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ TestSegment *segment = segment_list->Add(0x00410170, 0x10000, ".text", mtReadable | mtExecutable);
+ segment->set_physical_size(sizeof(buf));
+ test_file.OpenFromMemory(buf, sizeof(buf));
+ func = reinterpret_cast<IntelFunction *>(arch.function_list()->AddByAddress(segment_list->item(0)->address(), ctVirtualization, 0, true, NULL));
+ EXPECT_EQ(func->count(), 69ul);
+ command = func->GetCommandByAddress(0x004101a1);
+ EXPECT_EQ(command->link()->type(), ltFilterSEHBlock);
+ command = func->GetCommandByAddress(0x004101DB);
+ EXPECT_EQ(command->text(), "dd 00000001");
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 00419054");
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 004101E7");
+ EXPECT_EQ(command->link()->type(), ltMemSEHBlock);
+ command = func->GetCommandByAddress(0x00410229);
+ EXPECT_EQ(command->link()->type(), ltFinallyBlock);
+ // Check CompileToNative
+ std::vector<uint8_t> data;
+ size_t i, j;
+ for (i = 0; i < func->count(); i++) {
+ command = func->item(i);
+ if ((command->type() == cmJmpWithFlag || command->type() == cmJmp || command->type() == cmCall) && command->dump_size() == 2)
+ continue;
+
+ data.clear();
+ for (j = 0; j < command->dump_size(); j++) {
+ data.push_back(command->dump(j));
+ }
+ command->CompileToNative();
+ EXPECT_EQ(command->dump_size(), data.size());
+ for (j = 0; j < command->dump_size(); j++) {
+ EXPECT_EQ(command->dump(j), data[j]);
+ }
+ }
+ // Check the compilation prepare
+ MemoryManager manager(&arch);
+ CompileContext ctx;
+ ctx.file = &arch;
+ ctx.manager = &manager;
+ ASSERT_TRUE(func->Prepare(ctx));
+ ASSERT_TRUE(func->PrepareExtCommands(ctx));
+ ASSERT_EQ(manager.count(), 2ul);
+ MemoryRegion *region = manager.item(0);
+ EXPECT_EQ(region->address(), 0x00410175ull);
+ EXPECT_EQ(region->size(), 0x66ul);
+ EXPECT_EQ((int)region->type(), (mtReadable | mtExecutable));
+ region = manager.item(1);
+ EXPECT_EQ(region->address(), 0x004101e7ull);
+ EXPECT_EQ(region->size(), 0x60ul);
+ EXPECT_EQ((int)region->type(), (mtReadable | mtExecutable));
+}
+
+TEST(IntelTest, x86_ParseSDK)
+{
+ PEFile pf(NULL);
+ IntelFunction *func;
+ MapFunctionList *map_function_list;
+ MapFunction *map_function;
+ IntelCommand *command;
+
+ EXPECT_EQ(pf.Open("test-binaries/win32-app-test1-i386", foRead), osSuccess);
+ EXPECT_EQ(pf.count(), 1ul);
+ IArchitecture &arch = *pf.item(0);
+ map_function_list = arch.map_function_list();
+ map_function = map_function_list->GetFunctionByAddress(0x004011A3);
+ EXPECT_EQ(map_function->name().compare("VMProtectMarker \"Test marker\""), 0);
+ map_function = map_function_list->GetFunctionByAddress(0x00403049);
+ EXPECT_EQ(map_function->name().compare("string \"Correct password\""), 0);
+ map_function = map_function_list->GetFunctionByAddress(0x00403066);
+ EXPECT_EQ(map_function->name().compare("string \"Incorrect password\""), 0);
+ func = reinterpret_cast<IntelFunction *>(arch.function_list()->AddByAddress(0x004011A3, ctVirtualization, 0, true, NULL));
+ EXPECT_EQ(func->count(), 47ul);
+ // Check CompileToNative
+ std::vector<uint8_t> data;
+ size_t i, j;
+ for (i = 0; i < func->count(); i++) {
+ command = func->item(i);
+ if ((command->type() == cmJmpWithFlag || command->type() == cmJmp || command->type() == cmCall) && command->dump_size() == 2)
+ continue;
+
+ data.clear();
+ for (j = 0; j < command->dump_size(); j++) {
+ data.push_back(command->dump(j));
+ }
+ command->CompileToNative();
+ EXPECT_EQ(command->dump_size(), data.size());
+ for (j = 0; j < command->dump_size(); j++) {
+ EXPECT_EQ(command->dump(j), data[j]);
+ }
+ }
+}
+
+TEST(IntelTest, Clone)
+{
+ PEFile pf(NULL);
+
+ ASSERT_EQ(pf.Open("test-binaries/win32-app-test1-i386", foRead), osSuccess);
+ EXPECT_EQ(pf.count(), 1ul);
+ IFunctionList *function_list = pf.item(0)->function_list();
+ Folder *f1 = pf.folder_list()->Add("Folder1");
+ Folder *f2 = f1->Add("Folder2");
+ IFunction *func = function_list->AddByAddress(0x004011A3, ctUltra, 0, false, f2);
+ size_t command_count = func->count();
+ size_t link_count = func->link_list()->count();
+ uint64_t link_address = func->link_list()->item(2)->from_command()->address();
+ IFunctionList *clone_function_list = function_list->Clone(NULL);
+ pf.Close();
+ // Check clone function list.
+ //EXPECT_EQ(clone_function_list->root_folder()->count(), 1);
+ //EXPECT_EQ(clone_function_list->root_folder()->item(0)->count(), 1);
+ //EXPECT_EQ(clone_function_list->root_folder()->item(0)->name().compare("Folder1"), 0);
+
+ ASSERT_EQ(clone_function_list->count(), 1ul);
+ func = clone_function_list->item(0);
+ EXPECT_EQ(func->compilation_type(), ctUltra);
+ EXPECT_EQ(func->need_compile(), false);
+ //EXPECT_EQ(func->folder()->name().compare("Folder2"), 0);
+ ASSERT_EQ(func->count(), command_count);
+ ASSERT_EQ(func->link_list()->count(), link_count);
+ EXPECT_EQ(func->link_list()->item(2)->from_command()->address(), link_address);
+ delete clone_function_list;
+}
+
+TEST(IntelTest, x86_Switch)
+{
+ uint8_t buf[] = {
+ 0x83, 0xEC, 0x0C, // sub esp, 0C
+ 0x53, // push ebx
+ 0x56, // push esi
+ 0x57, // push edi
+ 0x89, 0x65, 0xE8, // mov [ebp-18], esp
+ 0x8B, 0xF1, // mov esi, ecx
+ 0x33, 0xC0, // xor eax, eax
+ 0x89, 0x45, 0xE4, // mov [ebp-1C], eax
+ 0x89, 0x45, 0xFC, // mov [ebp-04], eax
+ 0x52, // push edx
+ 0x51, // push ecx
+ 0x53, // push ebx
+ 0xB8, 0x68, 0x58, 0x4D, 0x56, // mov eax, 564D5868
+ 0x33, 0xDB, // xor ebx, ebx
+ 0xB9, 0x0A, 0x00, 0x00, 0x00, // mov ecx, 0000000A
+ 0xBA, 0x58, 0x56, 0x00, 0x00, // mov edx, 00005658
+ 0xED, // in eax, dx
+ 0x81, 0xFB, 0x68, 0x58, 0x4D, 0x56, // cmp ebx, 564D5868
+ 0x75, 0x03, // jnz 00403050
+ 0x89, 0x4D, 0xE4, // mov [ebp-1C], ecx
+ 0x5B, // pop ebx
+ 0x59, // pop ecx
+ 0x5A, // pop edx
+ 0x8B, 0x45, 0xE4, // mov eax, [ebp-1C]
+ 0x48, // dec eax
+ 0x83, 0xF8, 0x03, // cmp eax, 03
+ 0x0F, 0x87, 0x97, 0x00, 0x00, 0x00, // jnbe 004030F7
+ 0xFF, 0x24, 0x85, 0x40, 0x31, 0x40, 0x00, // jmp dword ptr [eax*4+00403140]
+ 0x68, 0x74, 0xD8, 0x4E, 0x00, // push 004ED874
+ 0xE8, 0xDF, 0x00, 0x00, 0x00, // call 00403150
+ 0xC7, 0x45, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, // mov dword ptr [ebp-04], FFFFFFFF
+ 0xB0, 0x01, // mov al, 01
+ 0x8B, 0x4D, 0xF0, // mov ecx, [ebp-10]
+ 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00, // mov fs:[00000000], ecx
+ 0x5F, // pop edi
+ 0x5E, // pop esi
+ 0x5B, // pop ebx
+ 0x8B, 0xE5, // mov esp, ebp
+ 0x5D, // pop ebp
+ 0xC3, // ret
+ 0x68, 0x94, 0xD8, 0x4E, 0x00, // push 004ED894
+ 0xE8, 0xBB, 0x00, 0x00, 0x00, // call 00403150
+ 0xC7, 0x45, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, // mov dword ptr [ebp-04], FFFFFFFF
+ 0xB0, 0x01, // mov al, 01
+ 0x8B, 0x4D, 0xF0, // mov ecx, [ebp-10]
+ 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00, // mov fs:[00000000], ecx
+ 0x5F, // pop edi
+ 0x5E, // pop esi
+ 0x5B, // pop ebx
+ 0x8B, 0xE5, // mov esp, ebp
+ 0x5D, // pop ebp
+ 0xC3, // ret
+ 0x68, 0xB8, 0xD8, 0x4E, 0x00, // push 004ED8B8
+ 0xE8, 0x97, 0x00, 0x00, 0x00, // call 00403150
+ 0xC7, 0x45, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, // mov dword ptr [ebp-04], FFFFFFFF
+ 0xB0, 0x01, // mov al, 01
+ 0x8B, 0x4D, 0xF0, // mov ecx, [ebp-10]
+ 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00, // mov fs:[00000000], ecx
+ 0x5F, // pop edi
+ 0x5E, // pop esi
+ 0x5B, // pop ebx
+ 0x8B, 0xE5, // mov esp, ebp
+ 0x5D, // pop ebp
+ 0xC3, // ret
+ 0x68, 0xDC, 0xD8, 0x4E, 0x00, // push 004ED8DC
+ 0xE8, 0x73, 0x00, 0x00, 0x00, // call 00403150
+ 0xC7, 0x45, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, // mov dword ptr [ebp-04], FFFFFFFF
+ 0xB0, 0x01, // mov al, 01
+ 0x8B, 0x4D, 0xF0, // mov ecx, [ebp-10]
+ 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00, // mov fs:[00000000], ecx
+ 0x5F, // pop edi
+ 0x5E, // pop esi
+ 0x5B, // pop ebx
+ 0x8B, 0xE5, // mov esp, ebp
+ 0x5D, // pop ebp
+ 0xC3, // ret
+ 0x68, 0x04, 0xD9, 0x4E, 0x00, // push 004ED904
+ 0xE8, 0x4F, 0x00, 0x00, 0x00, // call 00403150
+ 0xC7, 0x45, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, // mov dword ptr [ebp-04], FFFFFFFF
+ 0xB0, 0x01, // mov al, 01
+ 0x8B, 0x4D, 0xF0, // mov ecx, [ebp-10]
+ 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00, // mov fs:[00000000], ecx
+ 0x5F, // pop edi
+ 0x5E, // pop esi
+ 0x5B, // pop ebx
+ 0x8B, 0xE5, // mov esp, ebp
+ 0x5D, // pop ebp
+ 0xC3, // ret
+ 0xB8, 0x01, 0x00, 0x00, 0x00, // mov eax, 00000001
+ 0xC3, // ret
+ 0x8B, 0x65, 0xE8, // mov esp, [ebp-18]
+ 0xC7, 0x45, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, // mov dword ptr [ebp-04], FFFFFFFF
+ 0x32, 0xC0, // xor al, al
+ 0x8B, 0x4D, 0xF0, // mov ecx, [ebp-10]
+ 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00, // mov fs:[00000000], ecx
+ 0x5F, // pop edi
+ 0x5E, // pop esi
+ 0x5B, // pop ebx
+ 0x8B, 0xE5, // mov esp, ebp
+ 0x5D, // pop ebp
+ 0xC3, // ret
+ 0xCD, 0xCD, // alignment
+ 0x67, 0x30, 0x40, 0x00, // dd 00403067
+ 0x8B, 0x30, 0x40, 0x00, // dd 0040308B
+ 0xAF, 0x30, 0x40, 0x00, // dd 004030AF
+ 0xD3, 0x30, 0x40, 0x00, // dd 004030D3
+ 0x00, 0x00, 0x00, 0x00 // dd 0
+ };
+
+ ICommand *command;
+ IntelFunction *func;
+ TestFile test_file(osDWord);
+ IArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ TestSegment *segment = segment_list->Add(0x0040301D, 0x10000, ".text", mtReadable | mtExecutable);
+ segment->set_physical_size(sizeof(buf));
+ test_file.OpenFromMemory(buf, sizeof(buf));
+ func = reinterpret_cast<IntelFunction *>(arch.function_list()->AddByAddress(segment_list->item(0)->address(), ctVirtualization, 0, true, NULL));
+ ASSERT_EQ(func->count(), 92ul);
+ command = func->GetCommandByAddress(0x00403140);
+ EXPECT_EQ(command->text(), "dd 00403067");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 0040308B");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 004030AF");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 004030D3");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ // Check CompileToNative
+ std::vector<uint8_t> data;
+ size_t i, j;
+ for (i = 0; i < func->count(); i++) {
+ command = func->item(i);
+ if ((command->type() == cmJmpWithFlag || command->type() == cmJmp || command->type() == cmCall) && command->dump_size() == 2)
+ continue;
+
+ data.clear();
+ for (j = 0; j < command->dump_size(); j++) {
+ data.push_back(command->dump(j));
+ }
+ command->CompileToNative();
+ EXPECT_EQ(command->dump_size(), data.size());
+ for (j = 0; j < command->dump_size(); j++) {
+ EXPECT_EQ(command->dump(j), data[j]);
+ }
+ }
+ // Check the compilation prepare
+ MemoryManager manager(&arch);
+ CompileContext ctx;
+ ctx.file = &arch;
+ ctx.manager = &manager;
+ ASSERT_TRUE(func->Prepare(ctx));
+ ASSERT_TRUE(func->PrepareExtCommands(ctx));
+ ASSERT_EQ(manager.count(), 2ul);
+ MemoryRegion *region = manager.item(0);
+ EXPECT_EQ(region->address(), 0x00403022ull);
+ EXPECT_EQ(region->size(), 0xF9ul);
+ EXPECT_EQ((int)region->type(), (mtReadable | mtExecutable));
+ region = manager.item(1);
+ EXPECT_EQ(region->address(), 0x00403140ull);
+ EXPECT_EQ(region->size(), 0x10ul);
+ EXPECT_EQ((int)region->type(), (mtReadable | mtExecutable));
+}
+
+TEST(IntelTest, x86_MsvcSEH)
+{
+ uint8_t buf[] = {
+ 0x55, // push ebp
+ 0x8B, 0xEC, // mov ebp, esp
+ 0x6A, 0xFF, // push -01
+ 0x68, 0x48, 0x32, 0x40, 0x00, // push 00403248
+ 0x68, 0xE4, 0x7A, 0x4D, 0x00, // push 004D7AE4
+ 0x64, 0xA1, 0x00, 0x00, 0x00, 0x00, // mov eax, fs:[00000000]
+ 0x50, // push eax
+ 0x64, 0x89, 0x25, 0x00, 0x00, 0x00, 0x00, // mov fs:[00000000], esp
+ 0x83, 0xEC, 0x08, // sub esp, 08
+ 0x53, // push ebx
+ 0x56, // push esi
+ 0x57, // push edi
+ 0x89, 0x65, 0xE8, // mov [ebp-18], esp
+ 0xC7, 0x45, 0xFC, 0x00, 0x00, 0x00, 0x00, // mov dword ptr [ebp-04], 00000000
+ 0xB8, 0x01, 0x00, 0x00, 0x00, // mov eax, 00000001
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, // nop
+ 0x68, 0x14, 0xD9, 0x4E, 0x00, // push 004ED914
+ 0x8B, 0xF1, // mov esi, ecx
+ 0xE8, 0x47, 0xFF, 0xFF, 0xFF, // call 00403150
+ 0xC7, 0x45, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, // mov dword ptr [ebp-04], FFFFFFFF
+ 0xB0, 0x01, // mov al, 01
+ 0x8B, 0x4D, 0xF0, // mov ecx, [ebp-10]
+ 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00, // mov fs:[00000000], ecx
+ 0x5F, // pop edi
+ 0x5E, // pop esi
+ 0x5B, // pop ebx
+ 0x8B, 0xE5, // mov esp, ebp
+ 0x5D, // pop ebp
+ 0xC3, // ret
+ 0xB8, 0x01, 0x00, 0x00, 0x00, // mov eax, 00000001
+ 0xC3, // ret
+ 0x8B, 0x65, 0xE8, // mov esp, [ebp-18]
+ 0xC7, 0x45, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, // mov dword ptr [ebp-04], FFFFFFFF
+ 0x32, 0xC0, // xor al, al
+ 0x8B, 0x4D, 0xF0, // mov ecx, [ebp-10]
+ 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00, // mov fs:[00000000], ecx
+ 0x5F, // pop edi
+ 0x5E, // pop esi
+ 0x5B, // pop ebx
+ 0x8B, 0xE5, // mov esp, ebp
+ 0x5D, // pop ebp
+ 0xC3, // ret
+ 0xCD, 0xCD, // alignment
+ 0xFF, 0xFF, 0xFF, 0xFF, // dd FFFFFFFF
+ 0x23, 0x32, 0x40, 0x00, // dd 00403223
+ 0x29, 0x32, 0x40, 0x00, // dd 00403229
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0x00, 0x00, 0x00, 0x00 // dd 0
+ };
+
+ ICommand *command;
+ IntelFunction *func;
+ TestFile test_file(osDWord);
+ IArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ TestSegment *segment = segment_list->Add(0x004031C0, 0x10000, ".text", mtReadable | mtExecutable);
+ segment->set_physical_size(sizeof(buf));
+ test_file.OpenFromMemory(buf, sizeof(buf));
+ func = reinterpret_cast<IntelFunction *>(arch.function_list()->AddByAddress(segment_list->item(0)->address(), ctVirtualization, 0, true, NULL));
+ ASSERT_EQ(func->count(), 55ul);
+ command = func->GetCommandByAddress(0x00403248);
+ EXPECT_EQ(command->text(), "dd FFFFFFFF");
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 00403223");
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 00403229");
+ // Check CompileToNative
+ std::vector<uint8_t> data;
+ size_t i, j;
+ for (i = 0; i < func->count(); i++) {
+ command = func->item(i);
+ if ((command->type() == cmJmpWithFlag || command->type() == cmJmp || command->type() == cmCall) && command->dump_size() == 2)
+ continue;
+
+ data.clear();
+ for (j = 0; j < command->dump_size(); j++) {
+ data.push_back(command->dump(j));
+ }
+ command->CompileToNative();
+ EXPECT_EQ(command->dump_size(), data.size());
+ for (j = 0; j < command->dump_size(); j++) {
+ EXPECT_EQ(command->dump(j), data[j]);
+ }
+ }
+ // Check the compilation prepare
+ MemoryManager manager(&arch);
+ CompileContext ctx;
+ ctx.file = &arch;
+ ctx.manager = &manager;
+ ASSERT_TRUE(func->Prepare(ctx));
+ ASSERT_TRUE(func->PrepareExtCommands(ctx));
+ ASSERT_EQ(manager.count(), 1ul);
+ MemoryRegion *region = manager.item(0);
+ EXPECT_EQ(region->address(), 0x004031C5ull);
+ EXPECT_EQ(region->size(), 0x81ul);
+ EXPECT_EQ((int)region->type(), (mtReadable | mtExecutable));
+}
+
+TEST(IntelTest, x64_Switch)
+{
+ uint8_t buf[] = {
+ 0x83, 0xFB, 0x06, // cmp ebx, 06
+ 0x74, 0x0A, // jz 000000010001874A
+ 0x83, 0xFB, 0x07, // cmp ebx, 07
+ 0x74, 0x05, // jz 000000010001874A
+ 0x83, 0xFB, 0x08, // cmp ebx, 08
+ 0x75, 0x35, // jnz 000000010001877F
+ 0xBA, 0x04, 0xE8, 0x00, 0x00, // mov edx, 0000E804
+ 0xE8, 0xBA, 0x2B, 0x01, 0x00, // call 000000010002B30E
+ 0x48, 0x85, 0xC0, // test rax, rax
+ 0x74, 0x0A, // jz 0000000100018763
+ 0x33, 0xD2, // xor edx, edx
+ 0x48, 0x8B, 0xC8, // mov rcx, rax
+ 0xE8, 0x17, 0x20, 0x01, 0x00, // call 000000010002A77A
+ 0xBA, 0x05, 0xE8, 0x00, 0x00, // mov edx, 0000E805
+ 0x48, 0x8B, 0xCF, // mov rcx, rdi
+ 0xE8, 0x9E, 0x2B, 0x01, 0x00, // call 000000010002B30E
+ 0x48, 0x85, 0xC0, // test rax, rax
+ 0x74, 0x0A, // jz 000000010001877F
+ 0x33, 0xD2, // xor edx, edx
+ 0x48, 0x8B, 0xC8, // mov rcx, rax
+ 0xE8, 0xFB, 0x1F, 0x01, 0x00, // call 000000010002A77A
+ 0x8D, 0x43, 0xFF, // lea eax, [rbx-01]
+ 0x83, 0xF8, 0x09, // cmp eax, 09
+ 0x77, 0x27, // jnbe 00000001000187AE
+ 0x48, 0x8D, 0x15, 0x72, 0x78, 0xFE, 0xFF, // lea rdx, [0000000100000000]
+ 0x48, 0x98, // cdqe
+ 0x8B, 0x8C, 0x82, 0xF8, 0x87, 0x01, 0x00, // mov ecx, [rdx+rax*4+00000000000187F8]
+ 0x48, 0x03, 0xCA, // add rcx, rdx
+ 0xFF, 0xE1, // jmp rcx
+ 0x4C, 0x8B, 0x8F, 0x58, 0x01, 0x00, 0x00, // mov r9, [rdi+0000000000000158]
+ 0xEB, 0x10, // jmp 00000001000187B5
+ 0x4C, 0x8B, 0x8F, 0x60, 0x01, 0x00, 0x00, // mov r9, [rdi+0000000000000160]
+ 0xEB, 0x07, // jmp 00000001000187B5
+ 0x4C, 0x8B, 0x8F, 0x50, 0x01, 0x00, 0x00, // mov r9, [rdi+0000000000000150]
+ 0x48, 0x8B, 0x4F, 0x40, // mov rcx, [rdi+40]
+ 0xBA, 0x80, 0x00, 0x00, 0x00, // mov edx, 00000080
+ 0x44, 0x8D, 0x42, 0x81, // lea r8d, [rdx-7F]
+ 0xFF, 0x15, 0xA8, 0xA2, 0xFE, 0xFF, // call qword ptr [0000000100002A70]
+ 0x48, 0x8D, 0x0D, 0x81, 0x77, 0x02, 0x00, // lea rcx, [000000010003FF50]
+ 0x41, 0xB8, 0x01, 0x00, 0x00, 0x00, // mov r8d, 00000001
+ 0x8B, 0xD3, // mov edx, ebx
+ 0xE8, 0xD4, 0x77, 0x00, 0x00, // call 000000010001FFB0
+ 0x48, 0x8B, 0xCF, // mov rcx, rdi
+ 0x48, 0x8B, 0xD0, // mov rdx, rax
+ 0xE8, 0x87, 0x28, 0x01, 0x00, // call 000000010002B06E
+ 0x48, 0x8B, 0x7C, 0x24, 0x48, // mov rdi, [rsp+48]
+ 0x48, 0x8B, 0x5C, 0x24, 0x40, // mov rbx, [rsp+40]
+ 0x33, 0xC0, // xor eax, eax
+ 0x48, 0x83, 0xC4, 0x28, // add rsp, 28
+ 0xC3, // ret
+ 0xAE, 0x87, 0x01, 0x00, // dd 000187AE
+ 0xAE, 0x87, 0x01, 0x00, // dd 000187AE
+ 0xAE, 0x87, 0x01, 0x00, // dd 000187AE
+ 0xA5, 0x87, 0x01, 0x00, // dd 000187A5
+ 0xAE, 0x87, 0x01, 0x00, // dd 000187AE
+ 0x9C, 0x87, 0x01, 0x00, // dd 0001879C
+ 0x9C, 0x87, 0x01, 0x00, // dd 0001879C
+ 0xAE, 0x87, 0x01, 0x00, // dd 000187AE
+ 0xAE, 0x87, 0x01, 0x00, // dd 000187AE
+ 0xAE, 0x87, 0x01, 0x00, // dd 000187AE
+ 0x00, 0x00, 0x00, 0x00 // dd 0
+ };
+
+ ICommand *command;
+ IntelFunction *func;
+ TestFile test_file(osQWord);
+ IArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ TestSegment *segment = segment_list->Add(0x010001873Bull, 0x10000, ".text", mtReadable | mtExecutable);
+ segment->set_physical_size(sizeof(buf));
+ test_file.OpenFromMemory(buf, sizeof(buf));
+ func = reinterpret_cast<IntelFunction *>(arch.function_list()->AddByAddress(segment_list->item(0)->address(), ctVirtualization, 0, true, NULL));
+ EXPECT_EQ(func->count(), 60ul);
+ command = func->GetCommandByAddress(0x01000187F8ull);
+ EXPECT_EQ(command->text(), "dd 000187AE");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 000187AE");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 000187AE");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 000187A5");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 000187AE");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 0001879C");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 0001879C");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 000187AE");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 000187AE");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ command = func->GetCommandByAddress(command->next_address());
+ EXPECT_EQ(command->text(), "dd 000187AE");
+ EXPECT_EQ(command->link()->type(), ltCase);
+ // Check CompileToNative
+ std::vector<uint8_t> data;
+ size_t i, j;
+ for (i = 0; i < func->count(); i++) {
+ command = func->item(i);
+ if ((command->type() == cmJmpWithFlag || command->type() == cmJmp || command->type() == cmCall) && command->dump_size() == 2)
+ continue;
+
+ data.clear();
+ for (j = 0; j < command->dump_size(); j++) {
+ data.push_back(command->dump(j));
+ }
+ command->CompileToNative();
+ EXPECT_EQ(command->dump_size(), data.size());
+ for (j = 0; j < command->dump_size(); j++) {
+ EXPECT_EQ(command->dump(j), data[j]);
+ }
+ }
+ // Check the compilation prepare
+ MemoryManager manager(&arch);
+ CompileContext ctx;
+ ctx.file = &arch;
+ ctx.manager = &manager;
+ ASSERT_TRUE(func->Prepare(ctx));
+ ASSERT_TRUE(func->PrepareExtCommands(ctx));
+ ASSERT_EQ(manager.count(), 1ul);
+ MemoryRegion *region = manager.item(0);
+ EXPECT_EQ(region->address(), 0x0100018740ull);
+ EXPECT_EQ(region->size(), 0xe0ul);
+ EXPECT_EQ((int)region->type(), (mtReadable | mtExecutable));
+}
+
+TEST(IntelTest, x86_MsvcSEH2)
+{
+ uint8_t buf[] = {
+ 0x55, // push ebp
+ 0x8B, 0xEC, // mov ebp, esp
+ 0x6A, 0xFF, // push -01
+ 0x68, 0x7E, 0x10, 0x40, 0x00, // push 0040107E
+ 0x64, 0xA1, 0x00, 0x00, 0x00, 0x00, // mov eax, fs:[00000000]
+ 0x50, // push eax
+ 0x51, // push ecx
+ 0x53, // push ebx
+ 0x56, // push esi
+ 0x57, // push edi
+ 0xA1, 0x00, 0x30, 0x40, 0x00, // mov eax, [00403000]
+ 0x33, 0xC5, // xor eax, ebp
+ 0x50, // push eax
+ 0x8D, 0x45, 0xF4, // lea eax, [ebp-0C]
+ 0x64, 0xA3, 0x00, 0x00, 0x00, 0x00, // mov fs:[00000000], eax
+ 0x89, 0x65, 0xF0, // mov [ebp-10], esp
+ 0xC7, 0x45, 0xFC, 0x00, 0x00, 0x00, 0x00, // mov dword ptr [ebp-04], 00000000
+ 0x8B, 0x45, 0x08, // mov eax, [ebp+08]
+ 0x99, // cdq
+ 0x33, 0xC9, // xor ecx, ecx
+ 0xF7, 0xF9, // idiv ecx
+ 0x85, 0xC0, // test eax, eax
+ 0x75, 0x0E, // jnz 0040104A
+ 0x68, 0xF4, 0x20, 0x40, 0x00, // push 004020F4
+ 0xFF, 0x15, 0xA0, 0x20, 0x40, 0x00, // call dword ptr [004020A0]
+ 0x83, 0xC4, 0x04, // add esp, 04
+ 0xC7, 0x45, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, // mov dword ptr [ebp-04], FFFFFFFF
+ 0x8B, 0x4D, 0xF4, // mov ecx, [ebp-0C]
+ 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00, // mov fs:[00000000], ecx
+ 0x59, // pop ecx
+ 0x5F, // pop edi
+ 0x5E, // pop esi
+ 0x5B, // pop ebx
+ 0x8B, 0xE5, // mov esp, ebp
+ 0x5D, // pop ebp
+ 0xC3, // ret
+ 0x68, 0x00, 0x21, 0x40, 0x00, // push 00402100
+ 0xFF, 0x15, 0xA0, 0x20, 0x40, 0x00, // call dword ptr [004020A0]
+ 0x83, 0xC4, 0x04, // add esp, 04
+ 0xC7, 0x45, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, // mov dword ptr [ebp-04], FFFFFFFF
+ 0xB8, 0x51, 0x10, 0x40, 0x00, // mov eax, 00401051
+ 0xC3, // ret
+ 0x8B, 0x54, 0x24, 0x08, // mov edx, [esp+08]
+ 0x8D, 0x42, 0x0C, // lea eax, [edx+0C]
+ 0x8B, 0x4A, 0xEC, // mov ecx, [edx-14]
+ 0x33, 0xC8, // xor ecx, eax
+ 0xE8, 0xE3, 0xF7, 0xFF, 0xFF, // call 00401094
+ 0xB8, 0xD0, 0x10, 0x40, 0x00, // mov eax, 004010D0
+ 0xE9, 0xD3, 0xFF, 0xFF, 0xFF, // jmp 0040188E
+ 0xCD, 0xCD, 0xCD, // alignment
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0x63, 0x10, 0x40, 0x00, // dd 00401063
+ 0xFF, 0xFF, 0xFF, 0xFF, // dd FFFFFFFF
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0xFF, 0xFF, 0xFF, 0xFF, // dd FFFFFFFF
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0x01, 0x00, 0x00, 0x00, // dd 00000001
+ 0x01, 0x00, 0x00, 0x00, // dd 00000001
+ 0x9C, 0x10, 0x40, 0x00, // dd 0040109C
+ 0x22, 0x05, 0x93, 0x19, // dd 19930522
+ 0x02, 0x00, 0x00, 0x00, // dd 00000002
+ 0xAC, 0x10, 0x40, 0x00, // dd 004010AC
+ 0x01, 0x00, 0x00, 0x00, // dd 00000001
+ 0xBC, 0x10, 0x40, 0x00, // dd 004010BC
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ 0x00, 0x00, 0x00, 0x00, // dd 00000000
+ };
+
+ ICommand *command;
+ IntelFunction *func;
+ TestFile test_file(osDWord);
+ IArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ TestSegment *segment = segment_list->Add(0x00401000, 0x10000, ".text", mtReadable | mtExecutable);
+ segment->set_physical_size(sizeof(buf));
+ test_file.OpenFromMemory(buf, sizeof(buf));
+ func = reinterpret_cast<IntelFunction *>(arch.function_list()->AddByAddress(segment_list->item(0)->address(), ctVirtualization, 0, true, NULL));
+ ASSERT_EQ(func->count(), 64ul);
+ command = func->GetCommandByAddress(0x004010a8);
+ EXPECT_EQ(command->text(), "dd 00401063");
+ EXPECT_EQ(command->link()->type(), ltExtSEHHandler);
+ // Check CompileToNative
+ std::vector<uint8_t> data;
+ size_t i, j;
+ for (i = 0; i < func->count(); i++) {
+ command = func->item(i);
+ if ((command->type() == cmJmpWithFlag || command->type() == cmJmp || command->type() == cmCall) && command->dump_size() == 2)
+ continue;
+
+ data.clear();
+ for (j = 0; j < command->dump_size(); j++) {
+ data.push_back(command->dump(j));
+ }
+ command->CompileToNative();
+ EXPECT_EQ(command->dump_size(), data.size());
+ for (j = 0; j < command->dump_size(); j++) {
+ EXPECT_EQ(command->dump(j), data[j]);
+ }
+ }
+ // Check the compilation prepare
+ MemoryManager manager(&arch);
+ CompileContext ctx;
+ ctx.file = &arch;
+ ctx.manager = &manager;
+ ASSERT_TRUE(func->Prepare(ctx));
+ ASSERT_TRUE(func->PrepareExtCommands(ctx));
+ ASSERT_EQ(manager.count(), 1ul);
+ MemoryRegion *region = manager.item(0);
+ EXPECT_EQ(region->address(), 0x00401005ull);
+ EXPECT_EQ(region->size(), 0x79ul);
+ EXPECT_EQ((int)region->type(), (mtReadable | mtExecutable));
+}
+
+TEST(IntelTest, x86_FPU)
+{
+ uint8_t buf[] = {
+ 0x9B, 0xD9, 0x7D, 0xFC, // fstcw [ebp - 4]
+ 0x9B, 0xDD, 0x7D, 0xFC, // fstsw [ebp - 4]
+ 0x9B, // wait
+ 0x90, // nop
+ 0xD9, 0x7D, 0xFC, // fnstcw [ebp - 4]
+ 0xDD, 0x7D, 0xFC, // fnstsw [ebp - 4]
+ 0xC3, // ret
+ 0xCD, 0xCD, 0xCD, 0xCD, // alignment
+ };
+
+ IntelFunction *func;
+ TestFile test_file(osDWord);
+ IArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ TestSegment *segment = segment_list->Add(0x00401000, 0x10000, ".text", mtReadable | mtExecutable);
+ segment->set_physical_size(sizeof(buf));
+ test_file.OpenFromMemory(buf, sizeof(buf));
+ func = reinterpret_cast<IntelFunction *>(arch.function_list()->AddByAddress(segment_list->item(0)->address(), ctVirtualization, 0, true, NULL));
+ ASSERT_EQ(func->count(), 7ul);
+ EXPECT_EQ(func->item(0)->text(), "fstcw word ptr [ebp-04]");
+ EXPECT_EQ(func->item(1)->text(), "fstsw word ptr [ebp-04]");
+ EXPECT_EQ(func->item(4)->text(), "fnstcw word ptr [ebp-04]");
+ EXPECT_EQ(func->item(5)->text(), "fnstsw word ptr [ebp-04]");
+}
+
+TEST(IntelTest, x86_DisasmBranch1)
+{
+ uint8_t buf[] = {
+ 0x90, // nop
+ 0xE9, 0x01, 0x00, 0x00, 0x00, // jmp +1
+ 0xCC, // --
+ 0xE9, 0x01, 0x00, 0x00, 0x00, // jmp +1
+ 0xCC, // --
+ 0xC3, // ret
+ };
+
+ IntelFunction *func;
+ TestFile test_file(osDWord);
+ IArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ TestSegment *segment = segment_list->Add(0x00401000, 0x10000, ".text", mtReadable | mtExecutable);
+ segment->set_physical_size(sizeof(buf));
+ test_file.OpenFromMemory(buf, sizeof(buf));
+ func = reinterpret_cast<IntelFunction *>(arch.function_list()->AddByAddress(segment_list->item(0)->address(), ctVirtualization, 0, true, NULL));
+ ASSERT_EQ(func->count(), 2ul);
+}
+
+TEST(IntelTest, x86_DisasmBranch2)
+{
+ uint8_t buf[] = {
+ 0x90, // nop
+ 0xE9, 0x01, 0x00, 0x00, 0x00, // jmp +1
+ 0xCC, // --
+ 0x90, // nop
+ 0x90, // nop
+ 0x90, // nop
+ 0x90, // nop
+ 0xE9, 0x01, 0x00, 0x00, 0x00, // jmp +1
+ 0xCC, // --
+ 0x0F, 0x84, 0xF3, 0xFF, 0xFF, 0xFF, // jz -13
+ 0x90, // nop
+ 0xC3, // ret
+ };
+
+ IntelFunction *func;
+ TestFile test_file(osDWord);
+ IArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ TestSegment *segment = segment_list->Add(0x00401000, 0x10000, ".text", mtReadable | mtExecutable);
+ segment->set_physical_size(sizeof(buf));
+ test_file.OpenFromMemory(buf, sizeof(buf));
+ func = reinterpret_cast<IntelFunction *>(arch.function_list()->AddByAddress(segment_list->item(0)->address(), ctVirtualization, 0, true, NULL));
+ ASSERT_EQ(func->count(), 2ul);
+}
+
+TEST(IntelTest, x86_DisasmBranch3)
+{
+ uint8_t buf[] = {
+ 0x90, // nop
+ 0xE9, 0x01, 0x00, 0x00, 0x00, // jmp +1
+ 0xCC, // --
+ 0x90, // nop
+ 0x0F, 0x84, 0xF2, 0xFF, 0xFF, 0xFF, // jz -14
+ 0x90, // nop
+ 0x90, // nop
+ 0xE9, 0x01, 0x00, 0x00, 0x00, // jmp +1
+ 0xCC, // --
+ 0x0F, 0x84, 0xF3, 0xFF, 0xFF, 0xFF, // jz -13
+ 0x90, // nop
+ 0xC3, // ret
+ };
+
+ IntelFunction *func;
+ TestFile test_file(osDWord);
+ IArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ TestSegment *segment = segment_list->Add(0x00401000, 0x10000, ".text", mtReadable | mtExecutable);
+ segment->set_physical_size(sizeof(buf));
+ test_file.OpenFromMemory(buf, sizeof(buf));
+ func = reinterpret_cast<IntelFunction *>(arch.function_list()->AddByAddress(segment_list->item(0)->address(), ctVirtualization, 0, true, NULL));
+ ASSERT_EQ(func->count(), 10ul);
+}
+
+TEST(IntelTest, x86_DisasmBranch4)
+{
+ uint8_t buf[] = {
+ 0x90, // nop
+ 0xE9, 0x03, 0x00, 0x00, 0x00, // jmp +3
+ 0xCC, // --
+ 0x90, // nop
+ 0x90, // nop
+ 0x90, // nop
+ 0x90, // nop
+ 0x0F, 0x84, 0xF6, 0xFF, 0xFF, 0xFF, // jz -10
+ 0x90, // nop
+ 0x90, // nop
+ 0xE9, 0x01, 0x00, 0x00, 0x00, // jmp +1
+ 0xCC, // --
+ 0x0F, 0x84, 0xF3, 0xFF, 0xFF, 0xFF, // jz -13
+ 0x90, // nop
+ 0xC3, // ret
+ };
+
+ IntelFunction *func;
+ TestFile test_file(osDWord);
+ IArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ TestSegment *segment = segment_list->Add(0x00401000, 0x10000, ".text", mtReadable | mtExecutable);
+ segment->set_physical_size(sizeof(buf));
+ test_file.OpenFromMemory(buf, sizeof(buf));
+ func = reinterpret_cast<IntelFunction *>(arch.function_list()->AddByAddress(segment_list->item(0)->address(), ctVirtualization, 0, true, NULL));
+ ASSERT_EQ(func->count(), 13ul);
+}
+
+#ifdef _WIN32
+void CompileFunction(void *src, void *dest)
+{
+ uint8_t *buf = reinterpret_cast<uint8_t *>(src);
+ if (buf[0] == 0xe9) {
+ // jmp
+ uint32_t dw = *reinterpret_cast<uint32_t*>(&buf[1]);
+ buf = &buf[dw + 5];
+ }
+ TestFile test_file(osDWord);
+ IArchitecture &arch = *test_file.item(0);
+ TestSegmentList *segment_list = reinterpret_cast<TestSegmentList *>(arch.segment_list());
+ TestSegment *segment = segment_list->Add(reinterpret_cast<uint64_t>(dest), 0x1000, ".text", mtReadable | mtExecutable);
+ segment->set_physical_size(static_cast<uint32_t>(segment->size()));
+ test_file.OpenFromMemory(buf, static_cast<uint32_t>(0x1000 - 0x100));
+ IntelFunction *func = reinterpret_cast<IntelFunction *>(arch.function_list()->AddByAddress(segment->address(), ctVirtualization, 0, true, NULL));
+ for (size_t i = 0; i < func->count(); i++) {
+ IntelCommand *command = func->item(i);
+
+ if (command->type() == cmCall)
+ command->set_operand_value(0, command->operand(0).value + reinterpret_cast<uint64_t>(buf) - reinterpret_cast<uint64_t>(dest));
+ }
+ CompileOptions options;
+ options.flags = cpEncryptBytecode;
+ //int r = GetTickCount();
+ //printf("%d\n", r);
+ //srand(r);
+ arch.Compile(options, NULL);
+
+ arch.Seek(0);
+ arch.Read(dest, (size_t)arch.size());
+}
+
+void DoTestFunctionDWord(void *func_)
+{
+ void *address = VirtualAlloc(NULL, 0x20000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ ASSERT_TRUE(address != NULL);
+ CompileFunction(func_, address);
+
+ uint32_t orig_flags, flags;
+ uint32_t param1, param2, orig_res, res;
+ for (size_t i = 0; i < 100; i++) {
+ param1 = rand32();
+ param2 = rand32();
+ typedef uint32_t (tFunc)(uint32_t param1, uint32_t param2, uint32_t *flags);
+ orig_res = reinterpret_cast<tFunc *>(func_)(param1, param2, &orig_flags);
+ res = reinterpret_cast<tFunc *>(address)(param1, param2, &flags);
+ EXPECT_EQ(res, orig_res);
+ EXPECT_EQ(flags, orig_flags);
+ }
+
+ VirtualFree(address, 0, MEM_RELEASE);
+}
+
+void DoTestFunctionWord(void *func)
+{
+ void *address = VirtualAlloc(NULL, 0x20000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ ASSERT_TRUE(address != NULL);
+ CompileFunction(func, address);
+
+ uint32_t orig_flags, flags;
+ uint16_t param1, param2, orig_res, res;
+ for (size_t i = 0; i < 100; i++) {
+ param1 = rand();
+ param2 = rand();
+ typedef uint16_t (tFunc)(uint16_t param1, uint16_t param2, uint32_t *flags);
+ orig_res = reinterpret_cast<tFunc *>(func)(param1, param2, &orig_flags);
+ res = reinterpret_cast<tFunc *>(address)(param1, param2, &flags);
+ EXPECT_EQ(res, orig_res);
+ EXPECT_EQ(flags, orig_flags);
+ }
+
+ VirtualFree(address, 0, MEM_RELEASE);
+}
+
+void DoTestFunctionByte(void *func)
+{
+ void *address = VirtualAlloc(NULL, 0x20000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ ASSERT_TRUE(address != NULL);
+ CompileFunction(func, address);
+
+ uint32_t orig_flags, flags;
+ uint8_t param1, param2, orig_res;
+ for (size_t i = 0; i < 100; i++) {
+ param1 = rand();
+ param2 = rand();
+ typedef uint8_t (tFunc)(uint8_t param1, uint8_t param2, uint32_t *flags);
+ orig_res = reinterpret_cast<tFunc *>(func)(param1, param2, &orig_flags);
+ EXPECT_EQ(reinterpret_cast<tFunc *>(address)(param1, param2, &flags), orig_res);
+ EXPECT_EQ(flags, orig_flags);
+ }
+
+ VirtualFree(address, 0, MEM_RELEASE);
+}
+
+#ifndef _WIN64
+uint32_t AddDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ add eax, ecx
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t AddWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+
+ add ax, cx
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t AddByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ add al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationAdd)
+{
+ DoTestFunctionDWord(&AddDWord);
+ DoTestFunctionWord(&AddWord);
+ DoTestFunctionByte(&AddByte);
+}
+
+uint32_t AdcDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ adc eax, ecx
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t AdcWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ adc ax, cx
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t AdcByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+ cmp al, cl
+
+ adc al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationAdc)
+{
+ DoTestFunctionDWord(&AdcDWord);
+ DoTestFunctionWord(&AdcWord);
+ DoTestFunctionByte(&AdcByte);
+}
+
+uint32_t SubDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ sub eax, ecx
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t SubWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+
+ sub ax, cx
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t SubByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ sub al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationSub)
+{
+ DoTestFunctionDWord(&SubDWord);
+ DoTestFunctionWord(&SubWord);
+ DoTestFunctionByte(&SubByte);
+}
+
+uint32_t SbbDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ sbb eax, ecx
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t SbbWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ sbb ax, cx
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t SbbByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+ cmp al, cl
+
+ sbb al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationSbb)
+{
+ DoTestFunctionDWord(&SbbDWord);
+ DoTestFunctionWord(&SbbWord);
+ DoTestFunctionByte(&SbbByte);
+}
+
+uint32_t CmpDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ cmp eax, ecx
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t CmpWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+
+ cmp ax, cx
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t CmpByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ cmp al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationCmp)
+{
+ DoTestFunctionDWord(&CmpDWord);
+ DoTestFunctionWord(&CmpWord);
+ DoTestFunctionByte(&CmpByte);
+}
+
+uint32_t ShlDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ shl eax, cl
+
+ mov res, eax
+ pushfd
+ pop eax
+ and eax, ~fl_A
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t ShlWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+
+ shl ax, cl
+
+ mov res, ax
+ pushfd
+ pop eax
+ and eax, ~fl_A
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t ShlByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ shl al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ and eax, ~fl_A
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationShl)
+{
+ DoTestFunctionDWord(&ShlDWord);
+ DoTestFunctionWord(&ShlWord);
+ DoTestFunctionByte(&ShlByte);
+}
+
+uint32_t ShrDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ shr eax, cl
+
+ mov res, eax
+ pushfd
+ pop eax
+ and eax, ~fl_A
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t ShrWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+
+ shr ax, cl
+
+ mov res, ax
+ pushfd
+ pop eax
+ and eax, ~fl_A
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t ShrByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ shr al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ and eax, ~fl_A
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationShr)
+{
+ DoTestFunctionDWord(&ShrDWord);
+ DoTestFunctionWord(&ShrWord);
+ DoTestFunctionByte(&ShrByte);
+}
+
+uint32_t RolDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ rol eax, cl
+
+ mov res, eax
+ pushfd
+ pop eax
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t RolWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ rol ax, cl
+
+ mov res, ax
+ pushfd
+ pop eax
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t RolByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+ cmp al, cl
+
+ rol al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationRol)
+{
+ DoTestFunctionDWord(&RolDWord);
+ DoTestFunctionWord(&RolWord);
+ DoTestFunctionByte(&RolByte);
+}
+
+uint32_t RorDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ ror eax, cl
+
+ mov res, eax
+ pushfd
+ pop eax
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t RorWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ ror ax, cl
+
+ mov res, ax
+ pushfd
+ pop eax
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t RorByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+ cmp al, cl
+
+ ror al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationRor)
+{
+ DoTestFunctionDWord(&RorDWord);
+ DoTestFunctionWord(&RorWord);
+ DoTestFunctionByte(&RorByte);
+}
+
+uint32_t SarDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ sar eax, cl
+
+ mov res, eax
+ pushfd
+ pop eax
+ and eax, ~fl_A
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t SarWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+
+ sar ax, cl
+
+ mov res, ax
+ pushfd
+ pop eax
+ and eax, ~fl_A
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t SarByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ sar al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ and eax, ~fl_A
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationSar)
+{
+ DoTestFunctionDWord(&SarDWord);
+ DoTestFunctionWord(&SarWord);
+ DoTestFunctionByte(&SarByte);
+}
+
+uint32_t RclDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ rcl eax, cl
+
+ mov res, eax
+ pushfd
+ pop eax
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t RclWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ rcl ax, cl
+
+ mov res, ax
+ pushfd
+ pop eax
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t RclByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+ cmp al, cl
+
+ rcl al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationRcl)
+{
+ DoTestFunctionDWord(&RclDWord);
+ DoTestFunctionWord(&RclWord);
+ DoTestFunctionByte(&RclByte);
+}
+
+uint32_t RcrDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ rcr eax, cl
+
+ mov res, eax
+ pushfd
+ pop eax
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t RcrWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ rcr ax, cl
+
+ mov res, ax
+ pushfd
+ pop eax
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t RcrByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+ cmp al, cl
+
+ rcr al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ and cl, 31
+ jnz label_1
+ xor eax, eax
+label_1:
+ cmp cl, 1
+ jz label_2
+ and eax, ~fl_O
+label_2:
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationRcr)
+{
+ DoTestFunctionDWord(&RcrDWord);
+ DoTestFunctionWord(&RcrWord);
+ DoTestFunctionByte(&RcrByte);
+}
+
+uint32_t XorDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ xor eax, ecx
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t XorWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+
+ xor ax, cx
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t XorByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ xor al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationXor)
+{
+ DoTestFunctionDWord(&XorDWord);
+ DoTestFunctionWord(&XorWord);
+ DoTestFunctionByte(&XorByte);
+}
+
+uint32_t OrDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ or eax, ecx
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t OrWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+
+ or ax, cx
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t OrByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ or al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationOr)
+{
+ DoTestFunctionDWord(&OrDWord);
+ DoTestFunctionWord(&OrWord);
+ DoTestFunctionByte(&OrByte);
+}
+
+uint32_t AndDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ and eax, ecx
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t AndWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+
+ and ax, cx
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t AndByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ and al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationAnd)
+{
+ DoTestFunctionDWord(&AndDWord);
+ DoTestFunctionWord(&AndWord);
+ DoTestFunctionByte(&AndByte);
+}
+
+uint32_t TestDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ test eax, ecx
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t TestWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+
+ test ax, cx
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t TestByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ test al, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationTest)
+{
+ DoTestFunctionDWord(&TestDWord);
+ DoTestFunctionWord(&TestWord);
+ DoTestFunctionByte(&TestByte);
+}
+
+uint32_t NotDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ not eax
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t NotWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ not ax
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t NotByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+ cmp al, cl
+
+ not al
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationNot)
+{
+ DoTestFunctionDWord(&NotDWord);
+ DoTestFunctionWord(&NotWord);
+ DoTestFunctionByte(&NotByte);
+}
+
+uint32_t NegDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ neg eax
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t NegWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+
+ neg ax
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t NegByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ neg al
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationNeg)
+{
+ DoTestFunctionDWord(&NegDWord);
+ DoTestFunctionWord(&NegWord);
+ DoTestFunctionByte(&NegByte);
+}
+
+uint32_t XaddDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ mov res, eax
+
+ xadd res, ecx
+
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t XaddWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ mov res, ax
+
+ xadd res, cx
+
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t XaddByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+ mov res, al
+
+ xadd res, cl
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationXadd)
+{
+ DoTestFunctionDWord(&XaddDWord);
+ DoTestFunctionWord(&XaddWord);
+ DoTestFunctionByte(&XaddByte);
+}
+
+uint32_t XchgDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ xchg eax, ecx
+
+ mov res, eax
+ cmp eax, param1
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t XchgWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+
+ xchg ax, cx
+
+ mov res, ax
+ cmp ax, param1
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t XchgByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ xchg al, cl
+
+ mov res, al
+ cmp al, param1
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationXchg)
+{
+ DoTestFunctionDWord(&XchgDWord);
+ DoTestFunctionWord(&XchgWord);
+ DoTestFunctionByte(&XchgByte);
+}
+
+uint32_t IncDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ inc eax
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t IncWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ inc ax
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t IncByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+ cmp al, cl
+
+ inc al
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationInc)
+{
+ DoTestFunctionDWord(&IncDWord);
+ DoTestFunctionWord(&IncWord);
+ DoTestFunctionByte(&IncByte);
+}
+
+uint32_t DecDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ dec eax
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t DecWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ dec ax
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t DecByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+ cmp al, cl
+
+ dec al
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationDec)
+{
+ DoTestFunctionDWord(&DecDWord);
+ DoTestFunctionWord(&DecWord);
+ DoTestFunctionByte(&DecByte);
+}
+
+uint32_t MulDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ push edx
+ mov eax, param1
+ mov ecx, param2
+
+ mul ecx
+
+ pushfd
+ add eax, edx
+ mov res, eax
+ pop eax
+ and eax, ~(fl_S | fl_Z | fl_A | fl_P)
+ mov ecx, flags
+ mov [ecx], eax
+ pop edx
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t MulWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ push edx
+ mov ax, param1
+
+ mul param2
+
+ pushfd
+ add ax, dx
+ mov res, ax
+ pop eax
+ and eax, ~(fl_S | fl_Z | fl_A | fl_P)
+ mov ecx, flags
+ mov [ecx], eax
+ pop edx
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t MulByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ mul cl
+
+ pushfd
+ add al, ah
+ mov res, al
+ pop eax
+ and eax, ~(fl_S | fl_Z | fl_A | fl_P)
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationMul)
+{
+ DoTestFunctionDWord(&MulDWord);
+ DoTestFunctionWord(&MulWord);
+ DoTestFunctionByte(&MulByte);
+}
+
+uint32_t ImulDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ push edx
+ mov eax, param1
+ mov ecx, param2
+
+ imul ecx
+
+ pushfd
+ add eax, edx
+ mov res, eax
+ pop eax
+ and eax, ~(fl_S | fl_Z | fl_A | fl_P)
+ mov ecx, flags
+ mov [ecx], eax
+ pop edx
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t ImulWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ push edx
+ mov ax, param1
+
+ imul param2
+
+ pushfd
+ add ax, dx
+ mov res, ax
+ pop eax
+ and eax, ~(fl_S | fl_Z | fl_A | fl_P)
+ mov ecx, flags
+ mov [ecx], eax
+ pop edx
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t ImulByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+
+ imul cl
+
+ pushfd
+ add al, ah
+ mov res, al
+ pop eax
+ and eax, ~(fl_S | fl_Z | fl_A | fl_P)
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationImul)
+{
+ DoTestFunctionDWord(&ImulDWord);
+ DoTestFunctionWord(&ImulWord);
+ DoTestFunctionByte(&ImulByte);
+}
+
+uint32_t BtDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ bt eax, cl
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t BtWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ bt ax, cl
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t BtMemDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ and ecx, 0x1f
+
+ bt param1, ecx
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t BtMemWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ and ecx, 0x0f
+
+ bt param1, cx
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t BtValDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ and ecx, 0x1f
+
+ bt param1, 0x18
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t BtValWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ and ecx, 0x0f
+
+ bt param1, 8
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationBt)
+{
+ DoTestFunctionDWord(&BtDWord);
+ DoTestFunctionWord(&BtWord);
+ DoTestFunctionDWord(&BtMemDWord);
+ DoTestFunctionWord(&BtMemWord);
+ DoTestFunctionDWord(&BtValDWord);
+ DoTestFunctionWord(&BtValWord);
+}
+
+uint32_t BtsDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ bts eax, cl
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t BtsWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ bts ax, cl
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t BtsMemDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ and ecx, 0x1f
+
+ bts param1, ecx
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t BtsMemWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ and ecx, 0x0f
+
+ bts param1, cx
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationBts)
+{
+ DoTestFunctionDWord(&BtsDWord);
+ DoTestFunctionWord(&BtsWord);
+ DoTestFunctionDWord(&BtsMemDWord);
+ DoTestFunctionWord(&BtsMemWord);
+}
+
+uint32_t BtrDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ btr eax, cl
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t BtrWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ btr ax, cl
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationBtr)
+{
+ DoTestFunctionDWord(&BtrDWord);
+ DoTestFunctionWord(&BtrWord);
+}
+
+uint32_t BtcDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ btc eax, cl
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t BtcWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ btc ax, cl
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationBtc)
+{
+ DoTestFunctionDWord(&BtcDWord);
+ DoTestFunctionWord(&BtcWord);
+}
+
+uint32_t CmovDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ cmp al, cl
+
+ cmovc eax, ecx
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t CmovWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ cmp al, cl
+
+ cmovna ax, cx
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationCmov)
+{
+ DoTestFunctionDWord(&CmovDWord);
+ DoTestFunctionWord(&CmovWord);
+}
+
+uint32_t LockAddDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ mov res, eax
+
+ lock add res, ecx
+
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov[ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint16_t LockAddWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ax, param1
+ mov cx, param2
+ mov res, ax
+
+ lock add res, cx
+
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov[ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t LockAddByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+ mov res, al
+
+ lock add res, cl
+
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov[ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t LockSubDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ mov res, eax
+
+ lock sub res, ecx
+
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov[ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t LockXorDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ mov res, eax
+
+ lock xor res, ecx
+
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov[ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t LockAndDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ mov res, eax
+
+ lock and res, ecx
+
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov[ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t LockOrDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ mov res, eax
+
+ lock or res, ecx
+
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov[ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t LockXchgDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ mov res, eax
+ cmp eax, ecx
+
+ lock xchg res, ecx
+ mov res, ecx
+
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov[ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t LockXaddDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ mov res, eax
+
+ lock xadd res, ecx
+ xor res, ecx
+
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov[ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationLock)
+{
+ DoTestFunctionDWord(&LockAddDWord);
+ DoTestFunctionWord(&LockAddWord);
+ DoTestFunctionByte(&LockAddByte);
+ DoTestFunctionDWord(&LockAndDWord);
+ DoTestFunctionDWord(&LockSubDWord);
+ DoTestFunctionDWord(&LockXorDWord);
+ DoTestFunctionDWord(&LockOrDWord);
+ DoTestFunctionDWord(&LockXchgDWord);
+ DoTestFunctionDWord(&LockXaddDWord);
+}
+
+uint32_t CbxDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+
+ cbw
+ movzx ecx, ax
+ mov eax, param2
+ cwd
+ add eax, ecx
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t MovzxDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+
+ lea ecx, param1
+ movzx eax, byte ptr [ecx + 1]
+ movzx ecx, word ptr [ecx + 2]
+
+ add eax, ecx
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t MovsxDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ movsx ecx, cl
+ movsx eax, ax
+
+ add eax, ecx
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t LahfByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov al, param1
+ mov cl, param2
+ cmp al, cl
+
+ lahf
+
+ mov res, ah
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t SahfByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov ah, param1
+
+ sahf
+
+ mov res, ah
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t StcByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ xor eax, eax
+
+ stc
+
+ setc res
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t ClcByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, -1
+ inc eax
+
+ clc
+
+ setc res
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint8_t CmcByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, -1
+ inc eax
+
+ cmc
+
+ setc res
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+
+uint8_t XlatByte(uint8_t param1, uint8_t param2, uint32_t *flags)
+{
+ uint8_t res;
+ uint8_t xlat_table[0x100];
+ for (size_t i = 0; i < 0x100; i++)
+ xlat_table[(uint8_t)i] = 0x100 - (uint8_t)i;
+ _asm {
+ push eax
+ push ecx
+
+ lea ebx, xlat_table
+ mov al, param1
+ xlat
+ add al, param2
+ xlat
+
+ mov res, al
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov[ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t BswapDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+
+ bswap eax
+
+ mov res, eax
+ add eax, param2
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t LeaDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+
+ lea eax, [ecx+eax*4+0x10000]
+
+ mov res, eax
+ xor eax, param2
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t ESPDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push eax
+ push ecx
+
+ mov eax, param1
+ mov [esp+4], eax
+ cmp eax, [esp+4]
+
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ pop eax
+ }
+ return res;
+}
+
+uint16_t SegWord(uint16_t param1, uint16_t param2, uint32_t *flags)
+{
+ uint16_t res;
+ _asm {
+ push eax
+ push ecx
+
+ push ss
+ pop eax
+
+ mov cx, ds
+ cmp ax, cx
+
+ mov res, ax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t LodsDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ push edi
+
+ lea esi, param1
+ lodsd
+ mov res, eax
+
+ mov ecx, flags
+ mov [ecx], esi
+ pop edi
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t RepStosDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ push edi
+
+ mov eax, param1
+ mov ecx, 4
+ lea edi, res
+ rep stosb
+
+ mov eax, ecx
+ mov ecx, flags
+ mov [ecx], eax
+ pop edi
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t LdsDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ uint8_t mem[6];
+
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ lea ecx, mem
+ mov [ecx], eax
+ mov ax, ds
+ mov [ecx+4], ax
+
+ lds eax, mem
+
+ mov res, ecx
+ cmp eax, ecx
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t PopESPDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ push edi
+
+ mov edi, esp
+ mov eax, param1
+ mov ecx, param2
+ push 0
+ push 0
+ xchg [esp], eax
+ pop dword ptr [esp]
+ pop eax
+ sub edi, esp
+
+ mov res, eax
+ mov ecx, flags
+ mov [ecx], edi
+ pop edi
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationOther)
+{
+ DoTestFunctionDWord(&CbxDWord);
+ DoTestFunctionDWord(&MovzxDWord);
+ DoTestFunctionDWord(&MovsxDWord);
+ DoTestFunctionByte(&LahfByte);
+ DoTestFunctionByte(&SahfByte);
+ DoTestFunctionByte(&StcByte);
+ DoTestFunctionByte(&ClcByte);
+ DoTestFunctionByte(&CmcByte);
+ DoTestFunctionDWord(&BswapDWord);
+ DoTestFunctionDWord(&LeaDWord);
+ DoTestFunctionDWord(&ESPDWord);
+ DoTestFunctionWord(&SegWord);
+ DoTestFunctionDWord(&LodsDWord);
+ DoTestFunctionDWord(&RepStosDWord);
+ DoTestFunctionDWord(&LdsDWord);
+ DoTestFunctionDWord(&PopESPDWord);
+ DoTestFunctionByte(&XlatByte);
+}
+
+uint32_t WriteStackDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ push edi
+
+ mov edi, esp
+ push ecx
+ mov [edi-4], eax
+ mov eax, [edi-4]
+ mov esp, edi
+
+ mov res, eax
+ mov ecx, flags
+ mov [ecx], edi
+ pop edi
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t ReadStackDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ push edi
+
+ mov edi, esp
+ push ecx
+ mov eax, [edi-4]
+ mov esp, edi
+
+ mov res, eax
+ mov ecx, flags
+ mov [ecx], edi
+ pop edi
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationStack)
+{
+ DoTestFunctionDWord(&ReadStackDWord);
+ DoTestFunctionDWord(&WriteStackDWord);
+}
+
+uint32_t JxxDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+
+ cmp eax, param2
+ jnl label_0
+ not eax
+label_0:
+ test eax, 1
+ jnz label_1
+ add eax, param2
+ jc label_2
+ or al, 1
+ jmp label_0
+label_2:
+ rol eax, 1
+
+label_1:
+ mov res, eax
+ pushfd
+ pop eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t LoopDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ movzx ecx, cl
+
+ jecxz label_1
+label_0:
+ add eax, eax
+ loop label_0
+
+label_1:
+ mov res, eax
+ mov eax, ecx
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t LoopeDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ movzx ecx, cl
+
+ jecxz label_1
+label_0:
+ add eax, eax
+ test ah, 1
+ loope label_0
+
+label_1:
+ mov res, eax
+ mov eax, ecx
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t LoopneDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+ mov eax, param1
+ mov ecx, param2
+ movzx ecx, cl
+
+ jecxz label_1
+label_0:
+ add eax, eax
+ test ah, 1
+ loopne label_0
+
+label_1:
+ mov res, eax
+ mov eax, ecx
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+uint32_t RetDWord(uint32_t param1, uint32_t param2, uint32_t *flags)
+{
+ uint32_t res;
+ _asm {
+ push eax
+ push ecx
+
+ push cs
+ mov eax, offset(label_1)
+ push eax
+ retf
+
+label_1:
+ mov eax, param1
+ mov res, eax
+ mov ecx, flags
+ mov [ecx], eax
+ pop ecx
+ pop eax
+ }
+ return res;
+}
+
+TEST(IntelTest, VirtualizationBranches)
+{
+ DoTestFunctionDWord(&JxxDWord);
+ DoTestFunctionDWord(&LoopDWord);
+ DoTestFunctionDWord(&LoopeDWord);
+ DoTestFunctionDWord(&LoopneDWord);
+ DoTestFunctionDWord(&RetDWord);
+ DoTestFunctionDWord(&CmovDWord);
+}
+#endif //_WIN64
+#endif //_WIN32
diff --git a/unit-tests/ipn_sqlclr.Test/Properties/AssemblyInfo.cs b/unit-tests/ipn_sqlclr.Test/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..b09320d
--- /dev/null
+++ b/unit-tests/ipn_sqlclr.Test/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+п»їusing System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ipn_sqlclr.Test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ipn_sqlclr.Test")]
+[assembly: AssemblyCopyright("Copyright В© 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("2ad5664f-7b08-40b7-a57a-2bca1f70ce55")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/unit-tests/ipn_sqlclr.Test/Service References/policyService/CertificateEnrollmentPolicy.wsdl b/unit-tests/ipn_sqlclr.Test/Service References/policyService/CertificateEnrollmentPolicy.wsdl
new file mode 100644
index 0000000..2c51dd3
--- /dev/null
+++ b/unit-tests/ipn_sqlclr.Test/Service References/policyService/CertificateEnrollmentPolicy.wsdl
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<wsdl:definitions xmlns:vscep="http://schemas.verisign.com/pkiservices/2009/07/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.verisign.com/pkiservices/2009/07/policy" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:types>
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:import schemaLocation="CertificateEnrollmentPolicy.xsd" namespace="http://schemas.verisign.com/pkiservices/2009/07/policy" />
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="requestPoliciesMessage">
+ <wsdl:part name="request" element="vscep:getPolicies" />
+ </wsdl:message>
+ <wsdl:message name="requestPoliciesResponse">
+ <wsdl:part name="response" element="vscep:getPoliciesResponse" />
+ </wsdl:message>
+ <wsdl:portType name="policy">
+ <wsdl:operation name="requestPolicies">
+ <wsdl:input wsaw:Action="http://schemas.verisign.com/pkiservices/2009/07/policy/getPolicies" message="vscep:requestPoliciesMessage" />
+ <wsdl:output wsaw:Action="http://schemas.verisign.com/pkiservices/2009/07/policy/getPoliciesResponse" message="vscep:requestPoliciesResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="requestPoliciesServiceSOAP" type="vscep:policy">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="requestPolicies">
+ <soap:operation soapAction="http://schemas.verisign.com/pkiservices/2009/07/policy/requestPolicies" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="policyService">
+ <wsdl:port name="requestPoliciesServiceSOAP" binding="vscep:requestPoliciesServiceSOAP">
+ <soap:address location="https://pki-ws.symauth.com/pki-ws/policyService" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions> \ No newline at end of file
diff --git a/unit-tests/ipn_sqlclr.Test/Service References/policyService/CertificateEnrollmentPolicy.xsd b/unit-tests/ipn_sqlclr.Test/Service References/policyService/CertificateEnrollmentPolicy.xsd
new file mode 100644
index 0000000..6e58e09
--- /dev/null
+++ b/unit-tests/ipn_sqlclr.Test/Service References/policyService/CertificateEnrollmentPolicy.xsd
@@ -0,0 +1,388 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xs:schema xmlns:vscep="http://schemas.verisign.com/pkiservices/2009/07/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" elementFormDefault="qualified" targetNamespace="http://schemas.verisign.com/pkiservices/2009/07/policy" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+ XML Schema for policyService Web Services
+ version 2.0
+ </xs:documentation>
+ </xs:annotation>
+ <xs:element name="getPolicies">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="version" type="vscep:VersionType" />
+ <xs:element minOccurs="0" name="clientTransactionID" type="vscep:TransactionIDType" />
+ <xs:element minOccurs="0" name="client" type="vscep:Client" />
+ <xs:element name="requestFilter" nillable="true" type="vscep:RequestFilter" />
+ <xs:element minOccurs="0" name="signResponse" type="xs:boolean" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:simpleType name="VersionType" final="restriction">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="\d{1,3}\.\d{0,3}" />
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType name="TransactionIDType" final="restriction">
+ <xs:restriction base="xs:string">
+ <xs:maxLength value="40" />
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:complexType name="Client">
+ <xs:sequence>
+ <xs:element name="lastUpdatetime" nillable="true" type="xs:dateTime" />
+ <xs:element name="preferredLanguage" nillable="true" type="xs:language" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="RequestFilter">
+ <xs:sequence>
+ <xs:element name="policyIDs" nillable="true" type="vscep:FilterOIDCollection" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="FilterOIDCollection">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="oid" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="getPoliciesResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="clientTransactionID" type="vscep:TransactionIDType" />
+ <xs:element name="serverTransactionID" type="vscep:TransactionIDType" />
+ <xs:element name="response" type="vscep:Response" />
+ <xs:element name="cAs" nillable="true" type="vscep:CACollection" />
+ <xs:element name="oIDs" nillable="true" type="vscep:OIDCollection" />
+ <xs:element minOccurs="0" name="signedEnrollmentPolicy" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="Response">
+ <xs:sequence>
+ <xs:element name="policyID" type="xs:string" />
+ <xs:element minOccurs="0" maxOccurs="1" name="policyFriendlyName" type="xs:string" />
+ <xs:element name="nextUpdateHours" nillable="true" type="xs:unsignedInt" />
+ <xs:element name="policiesNotChanged" type="xs:boolean" />
+ <xs:element name="policies" nillable="true" type="vscep:PolicyCollection" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="CACollection">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="cA" type="vscep:CA" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="CA">
+ <xs:sequence>
+ <xs:element minOccurs="0" maxOccurs="unbounded" name="uris" type="xs:anyURI" />
+ <xs:element name="certificate" type="xs:base64Binary" />
+ <xs:element name="cAIssuerName" nillable="true" type="xs:string" />
+ <xs:element name="cAReferenceID" type="xs:int" />
+ <xs:element name="cAType" nillable="true" type="vscep:CAType" />
+ <xs:element minOccurs="0" maxOccurs="unbounded" name="intermediateCACertificates" type="xs:base64Binary" />
+ <xs:element name="rootCACertificate" type="xs:base64Binary" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="OIDCollection">
+ <xs:sequence>
+ <xs:element minOccurs="1" maxOccurs="unbounded" name="oID" type="vscep:OID" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="OID">
+ <xs:sequence>
+ <xs:element name="value" type="xs:string" />
+ <xs:element name="oIDReferenceID" type="xs:int" />
+ <xs:element name="group" type="xs:unsignedInt" />
+ <xs:element name="defaultName" nillable="true" type="xs:string" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="PolicyCollection">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="policy" type="vscep:CertificateEnrollmentPolicy" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="CertificateEnrollmentPolicy">
+ <xs:sequence>
+ <xs:element name="policyOIDReference" type="xs:int" />
+ <xs:element name="cAs" type="vscep:CAReferenceCollection" />
+ <xs:element name="attributes" type="vscep:Attributes" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="CAReferenceCollection">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="cAReference" type="xs:int" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="Attributes">
+ <xs:sequence>
+ <xs:element name="policySchema" type="xs:int" />
+ <xs:element name="certificateValidity" type="vscep:CertificateValidity" />
+ <xs:element minOccurs="0" maxOccurs="1" name="certificateOverrideValidity" type="vscep:OverrideValidity" />
+ <xs:element name="subjectNameInfo" nillable="true" type="vscep:subjectName" />
+ <xs:element name="extensions" nillable="true" type="vscep:Extensions" />
+ <xs:element name="privateKeyAttributes" type="vscep:PrivateKeyInfo" />
+ <xs:element name="clientPolicy" nillable="true" type="vscep:ClientPolicy" />
+ <xs:element minOccurs="0" maxOccurs="1" name="systemInfo" type="vscep:SystemInformation" />
+ <xs:element name="rAPolicy" nillable="true" type="vscep:RAPolicy" />
+ <xs:element minOccurs="0" name="seatIdInfo" type="vscep:SeatInfoType" />
+ <xs:element name="applicationInstructions" nillable="true" type="vscep:ApplicationInstructionsType" />
+ <xs:element name="deploymentMode" type="xs:string" />
+ <xs:element name="status" type="xs:string" />
+ <xs:element name="migrationOIDs" nillable="true" type="vscep:MigrationOIDCollection" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="SystemInformation">
+ <xs:sequence>
+ <xs:element minOccurs="0" maxOccurs="1" name="searchCertificateData" type="vscep:SearchCertificateData" />
+ <xs:element minOccurs="0" maxOccurs="1" name="cACertPublish" type="vscep:PublishCert" />
+ <xs:element minOccurs="0" maxOccurs="1" name="cACertPublishNameValuePair" type="vscep:CACertPublishNameValuePair" />
+ <xs:element name="certificateDeliveryFormat" type="vscep:DeliveryFormat" />
+ <xs:element minOccurs="0" name="adminInfo" type="vscep:PersonalInfoType" />
+ <xs:element name="serviceEndpointList" nillable="true" type="vscep:ServiceEndpointListType" />
+ <xs:element name="duplicateCertPolicy" nillable="true" type="xs:string" />
+ <xs:element name="supersededPolicyOID" nillable="true" type="xs:string" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="MigrationOIDCollection">
+ <xs:sequence>
+ <xs:element minOccurs="0" maxOccurs="unbounded" name="migratedFromOID" type="xs:string" />
+ <xs:element name="migratedToOID" nillable="true" type="xs:string" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="PersonalInfoType">
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" />
+ <xs:element name="email" type="xs:string" />
+ <xs:element name="phone" nillable="true" type="xs:string" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="ServiceEndpointListType">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="serviceEndpoint" type="vscep:ServiceEndpointType" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="ServiceEndpointType">
+ <xs:sequence>
+ <xs:element name="type" type="xs:string" />
+ <xs:element name="endpointURI" type="xs:anyURI" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="SeatInfoType">
+ <xs:sequence>
+ <xs:element name="attributeNameValue" type="vscep:AttributeValueType" />
+ <xs:element name="attributeNameValueProperty" type="vscep:AttributeNameValuePropertyType" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="ApplicationInstructionsType">
+ <xs:sequence>
+ <xs:element name="fileContentType" type="xs:string" />
+ <xs:element name="url" type="xs:anyURI" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:simpleType name="DeliveryFormat">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" />
+ <xs:enumeration value="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#PKCS7" />
+ <xs:enumeration value="http://schemas.verisign.com/pkiservices/2009/07/PKCS12" />
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType name="CACertPublishNameValuePair">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="$publish_flag" />
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:complexType name="SearchCertificateData">
+ <xs:sequence>
+ <xs:element minOccurs="0" maxOccurs="unbounded" name="searchAttributeNameValuePair" type="vscep:AttributeNameValuePairType" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="CertificateValidity">
+ <xs:sequence>
+ <xs:element name="validityPeriodDays" type="xs:unsignedLong" />
+ <xs:element name="renewalPeriodDays" type="xs:unsignedLong" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="OverrideValidity">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="overrideFlag" type="xs:boolean" />
+ <xs:element minOccurs="0" maxOccurs="unbounded" name="overrideNameValuePair" type="vscep:validityNameValuePairNames" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:simpleType name="validityNameValuePairNames">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="$overrideValidityDays" />
+ <xs:enumeration value="$overrideValidityStartDate" />
+ <xs:enumeration value="$overrideValidityEndDate" />
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:complexType name="PrivateKeyInfo">
+ <xs:sequence>
+ <xs:element name="keysize" type="xs:int" />
+ <xs:element minOccurs="0" name="keyEscrowPolicy" type="vscep:KeyEscrowPolicyType" />
+ <xs:element name="keyexportable" type="xs:boolean" />
+ <xs:element minOccurs="0" name="keyprotect" type="xs:boolean" />
+ <xs:element name="algorithmOIDReference" nillable="true" type="xs:int" />
+ <xs:element name="cryptoProviders" nillable="true" type="vscep:CryptoProviders" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="KeyEscrowPolicyType">
+ <xs:sequence>
+ <xs:element name="keyEscrowEnabled" type="xs:boolean" />
+ <xs:element minOccurs="0" name="keyRecoveryDualAdminApprovalRequired" type="xs:boolean" />
+ <xs:element name="keyEscrowDeploymentMode" nillable="true" type="xs:string" />
+ <xs:element name="doKeyRecoveryForAdditionalEnrollRequest" nillable="true" type="xs:boolean" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="CryptoProviders">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="provider" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="ClientPolicy">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="clientName" type="xs:string" />
+ <xs:element minOccurs="0" name="maxPinLength" type="xs:int" />
+ <xs:element minOccurs="0" name="minPinLength" type="xs:int" />
+ <xs:element minOccurs="0" name="noOfBadAttempts" type="xs:int" />
+ <xs:element minOccurs="0" name="certRenewalOverlap" type="xs:int" />
+ <xs:element minOccurs="0" name="renewExpiredCerts" type="xs:boolean" />
+ <xs:element minOccurs="0" name="certRenewalMsg" type="xs:string" />
+ <xs:element minOccurs="0" name="certCleanUp" type="xs:boolean" />
+ <xs:element name="certPublish" type="vscep:PublishCert" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:simpleType name="PublishCert">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="yes" />
+ <xs:enumeration value="no" />
+ <xs:enumeration value="clientProvided" />
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:complexType name="RAPolicy">
+ <xs:sequence>
+ <xs:element name="registerUser" type="xs:boolean" />
+ <xs:element name="verifyUser" type="xs:boolean" />
+ <xs:element name="publishCert" type="vscep:PublishCert" />
+ <xs:element minOccurs="0" maxOccurs="unbounded" name="authorizationInfo" type="vscep:AuthorizationInfoType" />
+ <xs:element name="pollingPolicy" nillable="true" type="vscep:PollingPolicyType" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="AuthorizationInfoType">
+ <xs:sequence>
+ <xs:element name="userAuthorizationCollection" type="vscep:UserAuthorizationCollection" />
+ <xs:element name="directoryInfo" nillable="true" type="vscep:DirectoryInfoType" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="DirectoryInfoType">
+ <xs:sequence>
+ <xs:element name="directoryType" type="xs:string" />
+ <xs:element name="domainName" type="xs:string" />
+ <xs:choice>
+ <xs:element name="ipAddress" type="xs:string" />
+ <xs:element name="hostName" type="xs:string" />
+ </xs:choice>
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="UserAuthorizationCollection">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="authorizedGroup" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="PollingPolicyType">
+ <xs:sequence>
+ <xs:element name="gatewayPollingTime" type="vscep:PollingTimeType" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="PollingTimeType">
+ <xs:sequence>
+ <xs:element name="nextUpdateHours" type="xs:int" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="Extensions">
+ <xs:sequence>
+ <xs:element minOccurs="0" maxOccurs="unbounded" name="Extension" type="vscep:Extension" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="Extension">
+ <xs:sequence>
+ <xs:element name="extensionOIDReference" type="xs:int" />
+ <xs:element name="extensionCriticalFlag" type="xs:boolean" />
+ <xs:element name="extensionSyntax" nillable="true" type="vscep:extensionSyntax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="extensionSyntax">
+ <xs:sequence>
+ <xs:choice>
+ <xs:element minOccurs="0" maxOccurs="unbounded" name="extensionAttributeNameValuePair" type="vscep:AttributeNameValuePairType" />
+ <xs:element minOccurs="0" maxOccurs="unbounded" name="extensionValue" type="vscep:extensionValueType" />
+ </xs:choice>
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="AttributeNameValuePairType">
+ <xs:sequence>
+ <xs:element name="attributeName" type="xs:string" />
+ <xs:element name="attributeNameValue" nillable="true" type="vscep:AttributeValueType" />
+ <xs:element minOccurs="0" name="attributeNameValueProperty" type="vscep:AttributeNameValuePropertyType" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="AttributeValueType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="mandatory" type="xs:boolean" />
+ <xs:attribute name="type" type="xs:string" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="AttributeNameValuePropertyType">
+ <xs:sequence>
+ <xs:element name="value" nillable="true" type="xs:string" />
+ <xs:element minOccurs="0" name="source" type="xs:string" />
+ <xs:element minOccurs="0" name="sourceAttributeName" type="xs:string" />
+ <xs:element name="mandatory" nillable="true" type="xs:boolean" />
+ <xs:element name="overridable" nillable="true" type="xs:boolean" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="extensionValueType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="mandatory" type="xs:boolean" />
+ <xs:attribute name="type" type="xs:string" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="subjectName">
+ <xs:sequence>
+ <xs:element minOccurs="0" maxOccurs="unbounded" name="subjectNameAttribute" type="vscep:subjectNameAttribute" />
+ <xs:element name="overrideSubjectNameFormat" type="xs:boolean" />
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="subjectNameAttribute">
+ <xs:sequence>
+ <xs:element name="subjectNameAttributecount" nillable="true" type="xs:int" />
+ <xs:element minOccurs="1" maxOccurs="unbounded" name="subjectNameAttributeNameValuePair" type="vscep:AttributeNameValuePairType" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:simpleType name="CAType">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="public" />
+ <xs:enumeration value="private" />
+ </xs:restriction>
+ </xs:simpleType>
+</xs:schema> \ No newline at end of file
diff --git a/unit-tests/ipn_sqlclr.Test/Service References/policyService/Reference.cs b/unit-tests/ipn_sqlclr.Test/Service References/policyService/Reference.cs
new file mode 100644
index 0000000..c12c381
--- /dev/null
+++ b/unit-tests/ipn_sqlclr.Test/Service References/policyService/Reference.cs
@@ -0,0 +1,3010 @@
+п»ї//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.34014
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace ipn_sqlclr.Test.policyService {
+
+
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+ [System.ServiceModel.ServiceContractAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy", ConfigurationName="policyService.policy")]
+ public interface policy {
+
+ // CODEGEN: Generating message contract since the operation requestPolicies is neither RPC nor document wrapped.
+ [System.ServiceModel.OperationContractAttribute(Action="http://schemas.verisign.com/pkiservices/2009/07/policy/getPolicies", ReplyAction="http://schemas.verisign.com/pkiservices/2009/07/policy/getPoliciesResponse")]
+ [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
+ ipn_sqlclr.Test.policyService.requestPoliciesResponse requestPolicies(ipn_sqlclr.Test.policyService.requestPoliciesRequest request);
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class getPolicies : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string versionField;
+
+ private string clientTransactionIDField;
+
+ private Client clientField;
+
+ private RequestFilter requestFilterField;
+
+ private bool signResponseField;
+
+ private bool signResponseFieldSpecified;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public string version {
+ get {
+ return this.versionField;
+ }
+ set {
+ this.versionField = value;
+ this.RaisePropertyChanged("version");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public string clientTransactionID {
+ get {
+ return this.clientTransactionIDField;
+ }
+ set {
+ this.clientTransactionIDField = value;
+ this.RaisePropertyChanged("clientTransactionID");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=2)]
+ public Client client {
+ get {
+ return this.clientField;
+ }
+ set {
+ this.clientField = value;
+ this.RaisePropertyChanged("client");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=3)]
+ public RequestFilter requestFilter {
+ get {
+ return this.requestFilterField;
+ }
+ set {
+ this.requestFilterField = value;
+ this.RaisePropertyChanged("requestFilter");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=4)]
+ public bool signResponse {
+ get {
+ return this.signResponseField;
+ }
+ set {
+ this.signResponseField = value;
+ this.RaisePropertyChanged("signResponse");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool signResponseSpecified {
+ get {
+ return this.signResponseFieldSpecified;
+ }
+ set {
+ this.signResponseFieldSpecified = value;
+ this.RaisePropertyChanged("signResponseSpecified");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class Client : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private System.Nullable<System.DateTime> lastUpdatetimeField;
+
+ private string preferredLanguageField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=0)]
+ public System.Nullable<System.DateTime> lastUpdatetime {
+ get {
+ return this.lastUpdatetimeField;
+ }
+ set {
+ this.lastUpdatetimeField = value;
+ this.RaisePropertyChanged("lastUpdatetime");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(DataType="language", IsNullable=true, Order=1)]
+ public string preferredLanguage {
+ get {
+ return this.preferredLanguageField;
+ }
+ set {
+ this.preferredLanguageField = value;
+ this.RaisePropertyChanged("preferredLanguage");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=2)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class OID : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string valueField;
+
+ private int oIDReferenceIDField;
+
+ private uint groupField;
+
+ private string defaultNameField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public string value {
+ get {
+ return this.valueField;
+ }
+ set {
+ this.valueField = value;
+ this.RaisePropertyChanged("value");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public int oIDReferenceID {
+ get {
+ return this.oIDReferenceIDField;
+ }
+ set {
+ this.oIDReferenceIDField = value;
+ this.RaisePropertyChanged("oIDReferenceID");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=2)]
+ public uint group {
+ get {
+ return this.groupField;
+ }
+ set {
+ this.groupField = value;
+ this.RaisePropertyChanged("group");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=3)]
+ public string defaultName {
+ get {
+ return this.defaultNameField;
+ }
+ set {
+ this.defaultNameField = value;
+ this.RaisePropertyChanged("defaultName");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=4)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class CA : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string[] urisField;
+
+ private byte[] certificateField;
+
+ private string cAIssuerNameField;
+
+ private int cAReferenceIDField;
+
+ private System.Nullable<CAType> cATypeField;
+
+ private byte[][] intermediateCACertificatesField;
+
+ private byte[] rootCACertificateField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute("uris", DataType="anyURI", Order=0)]
+ public string[] uris {
+ get {
+ return this.urisField;
+ }
+ set {
+ this.urisField = value;
+ this.RaisePropertyChanged("uris");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary", Order=1)]
+ public byte[] certificate {
+ get {
+ return this.certificateField;
+ }
+ set {
+ this.certificateField = value;
+ this.RaisePropertyChanged("certificate");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=2)]
+ public string cAIssuerName {
+ get {
+ return this.cAIssuerNameField;
+ }
+ set {
+ this.cAIssuerNameField = value;
+ this.RaisePropertyChanged("cAIssuerName");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=3)]
+ public int cAReferenceID {
+ get {
+ return this.cAReferenceIDField;
+ }
+ set {
+ this.cAReferenceIDField = value;
+ this.RaisePropertyChanged("cAReferenceID");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=4)]
+ public System.Nullable<CAType> cAType {
+ get {
+ return this.cATypeField;
+ }
+ set {
+ this.cATypeField = value;
+ this.RaisePropertyChanged("cAType");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute("intermediateCACertificates", DataType="base64Binary", Order=5)]
+ public byte[][] intermediateCACertificates {
+ get {
+ return this.intermediateCACertificatesField;
+ }
+ set {
+ this.intermediateCACertificatesField = value;
+ this.RaisePropertyChanged("intermediateCACertificates");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary", Order=6)]
+ public byte[] rootCACertificate {
+ get {
+ return this.rootCACertificateField;
+ }
+ set {
+ this.rootCACertificateField = value;
+ this.RaisePropertyChanged("rootCACertificate");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=7)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public enum CAType {
+
+ /// <remarks/>
+ @public,
+
+ /// <remarks/>
+ @private,
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class MigrationOIDCollection : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string[] migratedFromOIDField;
+
+ private string migratedToOIDField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute("migratedFromOID", Order=0)]
+ public string[] migratedFromOID {
+ get {
+ return this.migratedFromOIDField;
+ }
+ set {
+ this.migratedFromOIDField = value;
+ this.RaisePropertyChanged("migratedFromOID");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=1)]
+ public string migratedToOID {
+ get {
+ return this.migratedToOIDField;
+ }
+ set {
+ this.migratedToOIDField = value;
+ this.RaisePropertyChanged("migratedToOID");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=2)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class ApplicationInstructionsType : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string fileContentTypeField;
+
+ private string urlField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public string fileContentType {
+ get {
+ return this.fileContentTypeField;
+ }
+ set {
+ this.fileContentTypeField = value;
+ this.RaisePropertyChanged("fileContentType");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(DataType="anyURI", Order=1)]
+ public string url {
+ get {
+ return this.urlField;
+ }
+ set {
+ this.urlField = value;
+ this.RaisePropertyChanged("url");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=2)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class SeatInfoType : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private AttributeValueType attributeNameValueField;
+
+ private AttributeNameValuePropertyType attributeNameValuePropertyField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public AttributeValueType attributeNameValue {
+ get {
+ return this.attributeNameValueField;
+ }
+ set {
+ this.attributeNameValueField = value;
+ this.RaisePropertyChanged("attributeNameValue");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public AttributeNameValuePropertyType attributeNameValueProperty {
+ get {
+ return this.attributeNameValuePropertyField;
+ }
+ set {
+ this.attributeNameValuePropertyField = value;
+ this.RaisePropertyChanged("attributeNameValueProperty");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=2)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class AttributeValueType : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private bool mandatoryField;
+
+ private bool mandatoryFieldSpecified;
+
+ private string typeField;
+
+ private string valueField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAttributeAttribute()]
+ public bool mandatory {
+ get {
+ return this.mandatoryField;
+ }
+ set {
+ this.mandatoryField = value;
+ this.RaisePropertyChanged("mandatory");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool mandatorySpecified {
+ get {
+ return this.mandatoryFieldSpecified;
+ }
+ set {
+ this.mandatoryFieldSpecified = value;
+ this.RaisePropertyChanged("mandatorySpecified");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAttributeAttribute()]
+ public string type {
+ get {
+ return this.typeField;
+ }
+ set {
+ this.typeField = value;
+ this.RaisePropertyChanged("type");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlTextAttribute()]
+ public string Value {
+ get {
+ return this.valueField;
+ }
+ set {
+ this.valueField = value;
+ this.RaisePropertyChanged("Value");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class AttributeNameValuePropertyType : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string valueField;
+
+ private string sourceField;
+
+ private string sourceAttributeNameField;
+
+ private System.Nullable<bool> mandatoryField;
+
+ private System.Nullable<bool> overridableField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=0)]
+ public string value {
+ get {
+ return this.valueField;
+ }
+ set {
+ this.valueField = value;
+ this.RaisePropertyChanged("value");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public string source {
+ get {
+ return this.sourceField;
+ }
+ set {
+ this.sourceField = value;
+ this.RaisePropertyChanged("source");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=2)]
+ public string sourceAttributeName {
+ get {
+ return this.sourceAttributeNameField;
+ }
+ set {
+ this.sourceAttributeNameField = value;
+ this.RaisePropertyChanged("sourceAttributeName");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=3)]
+ public System.Nullable<bool> mandatory {
+ get {
+ return this.mandatoryField;
+ }
+ set {
+ this.mandatoryField = value;
+ this.RaisePropertyChanged("mandatory");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=4)]
+ public System.Nullable<bool> overridable {
+ get {
+ return this.overridableField;
+ }
+ set {
+ this.overridableField = value;
+ this.RaisePropertyChanged("overridable");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class PollingTimeType : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private int nextUpdateHoursField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public int nextUpdateHours {
+ get {
+ return this.nextUpdateHoursField;
+ }
+ set {
+ this.nextUpdateHoursField = value;
+ this.RaisePropertyChanged("nextUpdateHours");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class PollingPolicyType : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private PollingTimeType gatewayPollingTimeField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public PollingTimeType gatewayPollingTime {
+ get {
+ return this.gatewayPollingTimeField;
+ }
+ set {
+ this.gatewayPollingTimeField = value;
+ this.RaisePropertyChanged("gatewayPollingTime");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=1)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class DirectoryInfoType : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string directoryTypeField;
+
+ private string domainNameField;
+
+ private string itemField;
+
+ private ItemChoiceType itemElementNameField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public string directoryType {
+ get {
+ return this.directoryTypeField;
+ }
+ set {
+ this.directoryTypeField = value;
+ this.RaisePropertyChanged("directoryType");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public string domainName {
+ get {
+ return this.domainNameField;
+ }
+ set {
+ this.domainNameField = value;
+ this.RaisePropertyChanged("domainName");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute("hostName", typeof(string), Order=2)]
+ [System.Xml.Serialization.XmlElementAttribute("ipAddress", typeof(string), Order=2)]
+ [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemElementName")]
+ public string Item {
+ get {
+ return this.itemField;
+ }
+ set {
+ this.itemField = value;
+ this.RaisePropertyChanged("Item");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=3)]
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public ItemChoiceType ItemElementName {
+ get {
+ return this.itemElementNameField;
+ }
+ set {
+ this.itemElementNameField = value;
+ this.RaisePropertyChanged("ItemElementName");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=4)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy", IncludeInSchema=false)]
+ public enum ItemChoiceType {
+
+ /// <remarks/>
+ hostName,
+
+ /// <remarks/>
+ ipAddress,
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class AuthorizationInfoType : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string[] userAuthorizationCollectionField;
+
+ private DirectoryInfoType directoryInfoField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlArrayAttribute(Order=0)]
+ [System.Xml.Serialization.XmlArrayItemAttribute("authorizedGroup", IsNullable=false)]
+ public string[] userAuthorizationCollection {
+ get {
+ return this.userAuthorizationCollectionField;
+ }
+ set {
+ this.userAuthorizationCollectionField = value;
+ this.RaisePropertyChanged("userAuthorizationCollection");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=1)]
+ public DirectoryInfoType directoryInfo {
+ get {
+ return this.directoryInfoField;
+ }
+ set {
+ this.directoryInfoField = value;
+ this.RaisePropertyChanged("directoryInfo");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=2)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class RAPolicy : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private bool registerUserField;
+
+ private bool verifyUserField;
+
+ private PublishCert publishCertField;
+
+ private AuthorizationInfoType[] authorizationInfoField;
+
+ private PollingPolicyType pollingPolicyField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public bool registerUser {
+ get {
+ return this.registerUserField;
+ }
+ set {
+ this.registerUserField = value;
+ this.RaisePropertyChanged("registerUser");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public bool verifyUser {
+ get {
+ return this.verifyUserField;
+ }
+ set {
+ this.verifyUserField = value;
+ this.RaisePropertyChanged("verifyUser");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=2)]
+ public PublishCert publishCert {
+ get {
+ return this.publishCertField;
+ }
+ set {
+ this.publishCertField = value;
+ this.RaisePropertyChanged("publishCert");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute("authorizationInfo", Order=3)]
+ public AuthorizationInfoType[] authorizationInfo {
+ get {
+ return this.authorizationInfoField;
+ }
+ set {
+ this.authorizationInfoField = value;
+ this.RaisePropertyChanged("authorizationInfo");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=4)]
+ public PollingPolicyType pollingPolicy {
+ get {
+ return this.pollingPolicyField;
+ }
+ set {
+ this.pollingPolicyField = value;
+ this.RaisePropertyChanged("pollingPolicy");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=5)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public enum PublishCert {
+
+ /// <remarks/>
+ yes,
+
+ /// <remarks/>
+ no,
+
+ /// <remarks/>
+ clientProvided,
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class ServiceEndpointType : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string typeField;
+
+ private string endpointURIField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public string type {
+ get {
+ return this.typeField;
+ }
+ set {
+ this.typeField = value;
+ this.RaisePropertyChanged("type");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(DataType="anyURI", Order=1)]
+ public string endpointURI {
+ get {
+ return this.endpointURIField;
+ }
+ set {
+ this.endpointURIField = value;
+ this.RaisePropertyChanged("endpointURI");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=2)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class PersonalInfoType : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string nameField;
+
+ private string emailField;
+
+ private string phoneField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public string name {
+ get {
+ return this.nameField;
+ }
+ set {
+ this.nameField = value;
+ this.RaisePropertyChanged("name");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public string email {
+ get {
+ return this.emailField;
+ }
+ set {
+ this.emailField = value;
+ this.RaisePropertyChanged("email");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=2)]
+ public string phone {
+ get {
+ return this.phoneField;
+ }
+ set {
+ this.phoneField = value;
+ this.RaisePropertyChanged("phone");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=3)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class SystemInformation : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private AttributeNameValuePairType[] searchCertificateDataField;
+
+ private PublishCert cACertPublishField;
+
+ private bool cACertPublishFieldSpecified;
+
+ private CACertPublishNameValuePair cACertPublishNameValuePairField;
+
+ private bool cACertPublishNameValuePairFieldSpecified;
+
+ private DeliveryFormat certificateDeliveryFormatField;
+
+ private PersonalInfoType adminInfoField;
+
+ private ServiceEndpointType[] serviceEndpointListField;
+
+ private string duplicateCertPolicyField;
+
+ private string supersededPolicyOIDField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlArrayAttribute(Order=0)]
+ [System.Xml.Serialization.XmlArrayItemAttribute("searchAttributeNameValuePair", IsNullable=false)]
+ public AttributeNameValuePairType[] searchCertificateData {
+ get {
+ return this.searchCertificateDataField;
+ }
+ set {
+ this.searchCertificateDataField = value;
+ this.RaisePropertyChanged("searchCertificateData");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public PublishCert cACertPublish {
+ get {
+ return this.cACertPublishField;
+ }
+ set {
+ this.cACertPublishField = value;
+ this.RaisePropertyChanged("cACertPublish");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool cACertPublishSpecified {
+ get {
+ return this.cACertPublishFieldSpecified;
+ }
+ set {
+ this.cACertPublishFieldSpecified = value;
+ this.RaisePropertyChanged("cACertPublishSpecified");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=2)]
+ public CACertPublishNameValuePair cACertPublishNameValuePair {
+ get {
+ return this.cACertPublishNameValuePairField;
+ }
+ set {
+ this.cACertPublishNameValuePairField = value;
+ this.RaisePropertyChanged("cACertPublishNameValuePair");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool cACertPublishNameValuePairSpecified {
+ get {
+ return this.cACertPublishNameValuePairFieldSpecified;
+ }
+ set {
+ this.cACertPublishNameValuePairFieldSpecified = value;
+ this.RaisePropertyChanged("cACertPublishNameValuePairSpecified");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=3)]
+ public DeliveryFormat certificateDeliveryFormat {
+ get {
+ return this.certificateDeliveryFormatField;
+ }
+ set {
+ this.certificateDeliveryFormatField = value;
+ this.RaisePropertyChanged("certificateDeliveryFormat");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=4)]
+ public PersonalInfoType adminInfo {
+ get {
+ return this.adminInfoField;
+ }
+ set {
+ this.adminInfoField = value;
+ this.RaisePropertyChanged("adminInfo");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true, Order=5)]
+ [System.Xml.Serialization.XmlArrayItemAttribute("serviceEndpoint", IsNullable=false)]
+ public ServiceEndpointType[] serviceEndpointList {
+ get {
+ return this.serviceEndpointListField;
+ }
+ set {
+ this.serviceEndpointListField = value;
+ this.RaisePropertyChanged("serviceEndpointList");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=6)]
+ public string duplicateCertPolicy {
+ get {
+ return this.duplicateCertPolicyField;
+ }
+ set {
+ this.duplicateCertPolicyField = value;
+ this.RaisePropertyChanged("duplicateCertPolicy");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=7)]
+ public string supersededPolicyOID {
+ get {
+ return this.supersededPolicyOIDField;
+ }
+ set {
+ this.supersededPolicyOIDField = value;
+ this.RaisePropertyChanged("supersededPolicyOID");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=8)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class AttributeNameValuePairType : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string attributeNameField;
+
+ private AttributeValueType attributeNameValueField;
+
+ private AttributeNameValuePropertyType attributeNameValuePropertyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public string attributeName {
+ get {
+ return this.attributeNameField;
+ }
+ set {
+ this.attributeNameField = value;
+ this.RaisePropertyChanged("attributeName");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=1)]
+ public AttributeValueType attributeNameValue {
+ get {
+ return this.attributeNameValueField;
+ }
+ set {
+ this.attributeNameValueField = value;
+ this.RaisePropertyChanged("attributeNameValue");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=2)]
+ public AttributeNameValuePropertyType attributeNameValueProperty {
+ get {
+ return this.attributeNameValuePropertyField;
+ }
+ set {
+ this.attributeNameValuePropertyField = value;
+ this.RaisePropertyChanged("attributeNameValueProperty");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public enum CACertPublishNameValuePair {
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlEnumAttribute("$publish_flag")]
+ publish_flag,
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public enum DeliveryFormat {
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlEnumAttribute("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X5" +
+ "09v3")]
+ httpdocsoasisopenorgwss200401oasis200401wssx509tokenprofile10X509v3,
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlEnumAttribute("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#PK" +
+ "CS7")]
+ httpdocsoasisopenorgwss200401oasis200401wssx509tokenprofile10PKCS7,
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlEnumAttribute("http://schemas.verisign.com/pkiservices/2009/07/PKCS12")]
+ httpschemasverisigncompkiservices200907PKCS12,
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class ClientPolicy : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string clientNameField;
+
+ private int maxPinLengthField;
+
+ private bool maxPinLengthFieldSpecified;
+
+ private int minPinLengthField;
+
+ private bool minPinLengthFieldSpecified;
+
+ private int noOfBadAttemptsField;
+
+ private bool noOfBadAttemptsFieldSpecified;
+
+ private int certRenewalOverlapField;
+
+ private bool certRenewalOverlapFieldSpecified;
+
+ private bool renewExpiredCertsField;
+
+ private bool renewExpiredCertsFieldSpecified;
+
+ private string certRenewalMsgField;
+
+ private bool certCleanUpField;
+
+ private bool certCleanUpFieldSpecified;
+
+ private PublishCert certPublishField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public string clientName {
+ get {
+ return this.clientNameField;
+ }
+ set {
+ this.clientNameField = value;
+ this.RaisePropertyChanged("clientName");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public int maxPinLength {
+ get {
+ return this.maxPinLengthField;
+ }
+ set {
+ this.maxPinLengthField = value;
+ this.RaisePropertyChanged("maxPinLength");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool maxPinLengthSpecified {
+ get {
+ return this.maxPinLengthFieldSpecified;
+ }
+ set {
+ this.maxPinLengthFieldSpecified = value;
+ this.RaisePropertyChanged("maxPinLengthSpecified");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=2)]
+ public int minPinLength {
+ get {
+ return this.minPinLengthField;
+ }
+ set {
+ this.minPinLengthField = value;
+ this.RaisePropertyChanged("minPinLength");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool minPinLengthSpecified {
+ get {
+ return this.minPinLengthFieldSpecified;
+ }
+ set {
+ this.minPinLengthFieldSpecified = value;
+ this.RaisePropertyChanged("minPinLengthSpecified");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=3)]
+ public int noOfBadAttempts {
+ get {
+ return this.noOfBadAttemptsField;
+ }
+ set {
+ this.noOfBadAttemptsField = value;
+ this.RaisePropertyChanged("noOfBadAttempts");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool noOfBadAttemptsSpecified {
+ get {
+ return this.noOfBadAttemptsFieldSpecified;
+ }
+ set {
+ this.noOfBadAttemptsFieldSpecified = value;
+ this.RaisePropertyChanged("noOfBadAttemptsSpecified");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=4)]
+ public int certRenewalOverlap {
+ get {
+ return this.certRenewalOverlapField;
+ }
+ set {
+ this.certRenewalOverlapField = value;
+ this.RaisePropertyChanged("certRenewalOverlap");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool certRenewalOverlapSpecified {
+ get {
+ return this.certRenewalOverlapFieldSpecified;
+ }
+ set {
+ this.certRenewalOverlapFieldSpecified = value;
+ this.RaisePropertyChanged("certRenewalOverlapSpecified");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=5)]
+ public bool renewExpiredCerts {
+ get {
+ return this.renewExpiredCertsField;
+ }
+ set {
+ this.renewExpiredCertsField = value;
+ this.RaisePropertyChanged("renewExpiredCerts");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool renewExpiredCertsSpecified {
+ get {
+ return this.renewExpiredCertsFieldSpecified;
+ }
+ set {
+ this.renewExpiredCertsFieldSpecified = value;
+ this.RaisePropertyChanged("renewExpiredCertsSpecified");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=6)]
+ public string certRenewalMsg {
+ get {
+ return this.certRenewalMsgField;
+ }
+ set {
+ this.certRenewalMsgField = value;
+ this.RaisePropertyChanged("certRenewalMsg");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=7)]
+ public bool certCleanUp {
+ get {
+ return this.certCleanUpField;
+ }
+ set {
+ this.certCleanUpField = value;
+ this.RaisePropertyChanged("certCleanUp");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool certCleanUpSpecified {
+ get {
+ return this.certCleanUpFieldSpecified;
+ }
+ set {
+ this.certCleanUpFieldSpecified = value;
+ this.RaisePropertyChanged("certCleanUpSpecified");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=8)]
+ public PublishCert certPublish {
+ get {
+ return this.certPublishField;
+ }
+ set {
+ this.certPublishField = value;
+ this.RaisePropertyChanged("certPublish");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=9)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class KeyEscrowPolicyType : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private bool keyEscrowEnabledField;
+
+ private bool keyRecoveryDualAdminApprovalRequiredField;
+
+ private bool keyRecoveryDualAdminApprovalRequiredFieldSpecified;
+
+ private string keyEscrowDeploymentModeField;
+
+ private System.Nullable<bool> doKeyRecoveryForAdditionalEnrollRequestField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public bool keyEscrowEnabled {
+ get {
+ return this.keyEscrowEnabledField;
+ }
+ set {
+ this.keyEscrowEnabledField = value;
+ this.RaisePropertyChanged("keyEscrowEnabled");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public bool keyRecoveryDualAdminApprovalRequired {
+ get {
+ return this.keyRecoveryDualAdminApprovalRequiredField;
+ }
+ set {
+ this.keyRecoveryDualAdminApprovalRequiredField = value;
+ this.RaisePropertyChanged("keyRecoveryDualAdminApprovalRequired");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool keyRecoveryDualAdminApprovalRequiredSpecified {
+ get {
+ return this.keyRecoveryDualAdminApprovalRequiredFieldSpecified;
+ }
+ set {
+ this.keyRecoveryDualAdminApprovalRequiredFieldSpecified = value;
+ this.RaisePropertyChanged("keyRecoveryDualAdminApprovalRequiredSpecified");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=2)]
+ public string keyEscrowDeploymentMode {
+ get {
+ return this.keyEscrowDeploymentModeField;
+ }
+ set {
+ this.keyEscrowDeploymentModeField = value;
+ this.RaisePropertyChanged("keyEscrowDeploymentMode");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=3)]
+ public System.Nullable<bool> doKeyRecoveryForAdditionalEnrollRequest {
+ get {
+ return this.doKeyRecoveryForAdditionalEnrollRequestField;
+ }
+ set {
+ this.doKeyRecoveryForAdditionalEnrollRequestField = value;
+ this.RaisePropertyChanged("doKeyRecoveryForAdditionalEnrollRequest");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=4)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class PrivateKeyInfo : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private int keysizeField;
+
+ private KeyEscrowPolicyType keyEscrowPolicyField;
+
+ private bool keyexportableField;
+
+ private bool keyprotectField;
+
+ private bool keyprotectFieldSpecified;
+
+ private System.Nullable<int> algorithmOIDReferenceField;
+
+ private string[] cryptoProvidersField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public int keysize {
+ get {
+ return this.keysizeField;
+ }
+ set {
+ this.keysizeField = value;
+ this.RaisePropertyChanged("keysize");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public KeyEscrowPolicyType keyEscrowPolicy {
+ get {
+ return this.keyEscrowPolicyField;
+ }
+ set {
+ this.keyEscrowPolicyField = value;
+ this.RaisePropertyChanged("keyEscrowPolicy");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=2)]
+ public bool keyexportable {
+ get {
+ return this.keyexportableField;
+ }
+ set {
+ this.keyexportableField = value;
+ this.RaisePropertyChanged("keyexportable");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=3)]
+ public bool keyprotect {
+ get {
+ return this.keyprotectField;
+ }
+ set {
+ this.keyprotectField = value;
+ this.RaisePropertyChanged("keyprotect");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool keyprotectSpecified {
+ get {
+ return this.keyprotectFieldSpecified;
+ }
+ set {
+ this.keyprotectFieldSpecified = value;
+ this.RaisePropertyChanged("keyprotectSpecified");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=4)]
+ public System.Nullable<int> algorithmOIDReference {
+ get {
+ return this.algorithmOIDReferenceField;
+ }
+ set {
+ this.algorithmOIDReferenceField = value;
+ this.RaisePropertyChanged("algorithmOIDReference");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true, Order=5)]
+ [System.Xml.Serialization.XmlArrayItemAttribute("provider", IsNullable=false)]
+ public string[] cryptoProviders {
+ get {
+ return this.cryptoProvidersField;
+ }
+ set {
+ this.cryptoProvidersField = value;
+ this.RaisePropertyChanged("cryptoProviders");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class extensionValueType : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private bool mandatoryField;
+
+ private bool mandatoryFieldSpecified;
+
+ private string typeField;
+
+ private string valueField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAttributeAttribute()]
+ public bool mandatory {
+ get {
+ return this.mandatoryField;
+ }
+ set {
+ this.mandatoryField = value;
+ this.RaisePropertyChanged("mandatory");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool mandatorySpecified {
+ get {
+ return this.mandatoryFieldSpecified;
+ }
+ set {
+ this.mandatoryFieldSpecified = value;
+ this.RaisePropertyChanged("mandatorySpecified");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAttributeAttribute()]
+ public string type {
+ get {
+ return this.typeField;
+ }
+ set {
+ this.typeField = value;
+ this.RaisePropertyChanged("type");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlTextAttribute()]
+ public string Value {
+ get {
+ return this.valueField;
+ }
+ set {
+ this.valueField = value;
+ this.RaisePropertyChanged("Value");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class extensionSyntax : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private object[] itemsField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute("extensionAttributeNameValuePair", typeof(AttributeNameValuePairType), Order=0)]
+ [System.Xml.Serialization.XmlElementAttribute("extensionValue", typeof(extensionValueType), Order=0)]
+ public object[] Items {
+ get {
+ return this.itemsField;
+ }
+ set {
+ this.itemsField = value;
+ this.RaisePropertyChanged("Items");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=1)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class Extension : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private int extensionOIDReferenceField;
+
+ private bool extensionCriticalFlagField;
+
+ private extensionSyntax extensionSyntaxField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public int extensionOIDReference {
+ get {
+ return this.extensionOIDReferenceField;
+ }
+ set {
+ this.extensionOIDReferenceField = value;
+ this.RaisePropertyChanged("extensionOIDReference");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public bool extensionCriticalFlag {
+ get {
+ return this.extensionCriticalFlagField;
+ }
+ set {
+ this.extensionCriticalFlagField = value;
+ this.RaisePropertyChanged("extensionCriticalFlag");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=2)]
+ public extensionSyntax extensionSyntax {
+ get {
+ return this.extensionSyntaxField;
+ }
+ set {
+ this.extensionSyntaxField = value;
+ this.RaisePropertyChanged("extensionSyntax");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class subjectNameAttribute : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private System.Nullable<int> subjectNameAttributecountField;
+
+ private AttributeNameValuePairType[] subjectNameAttributeNameValuePairField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=0)]
+ public System.Nullable<int> subjectNameAttributecount {
+ get {
+ return this.subjectNameAttributecountField;
+ }
+ set {
+ this.subjectNameAttributecountField = value;
+ this.RaisePropertyChanged("subjectNameAttributecount");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute("subjectNameAttributeNameValuePair", Order=1)]
+ public AttributeNameValuePairType[] subjectNameAttributeNameValuePair {
+ get {
+ return this.subjectNameAttributeNameValuePairField;
+ }
+ set {
+ this.subjectNameAttributeNameValuePairField = value;
+ this.RaisePropertyChanged("subjectNameAttributeNameValuePair");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class subjectName : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private subjectNameAttribute[] subjectNameAttributeField;
+
+ private bool overrideSubjectNameFormatField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute("subjectNameAttribute", Order=0)]
+ public subjectNameAttribute[] subjectNameAttribute {
+ get {
+ return this.subjectNameAttributeField;
+ }
+ set {
+ this.subjectNameAttributeField = value;
+ this.RaisePropertyChanged("subjectNameAttribute");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public bool overrideSubjectNameFormat {
+ get {
+ return this.overrideSubjectNameFormatField;
+ }
+ set {
+ this.overrideSubjectNameFormatField = value;
+ this.RaisePropertyChanged("overrideSubjectNameFormat");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=2)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class OverrideValidity : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private bool overrideFlagField;
+
+ private bool overrideFlagFieldSpecified;
+
+ private validityNameValuePairNames[] overrideNameValuePairField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public bool overrideFlag {
+ get {
+ return this.overrideFlagField;
+ }
+ set {
+ this.overrideFlagField = value;
+ this.RaisePropertyChanged("overrideFlag");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlIgnoreAttribute()]
+ public bool overrideFlagSpecified {
+ get {
+ return this.overrideFlagFieldSpecified;
+ }
+ set {
+ this.overrideFlagFieldSpecified = value;
+ this.RaisePropertyChanged("overrideFlagSpecified");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute("overrideNameValuePair", Order=1)]
+ public validityNameValuePairNames[] overrideNameValuePair {
+ get {
+ return this.overrideNameValuePairField;
+ }
+ set {
+ this.overrideNameValuePairField = value;
+ this.RaisePropertyChanged("overrideNameValuePair");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public enum validityNameValuePairNames {
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlEnumAttribute("$overrideValidityDays")]
+ overrideValidityDays,
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlEnumAttribute("$overrideValidityStartDate")]
+ overrideValidityStartDate,
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlEnumAttribute("$overrideValidityEndDate")]
+ overrideValidityEndDate,
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class CertificateValidity : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private ulong validityPeriodDaysField;
+
+ private ulong renewalPeriodDaysField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public ulong validityPeriodDays {
+ get {
+ return this.validityPeriodDaysField;
+ }
+ set {
+ this.validityPeriodDaysField = value;
+ this.RaisePropertyChanged("validityPeriodDays");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public ulong renewalPeriodDays {
+ get {
+ return this.renewalPeriodDaysField;
+ }
+ set {
+ this.renewalPeriodDaysField = value;
+ this.RaisePropertyChanged("renewalPeriodDays");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class Attributes : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private int policySchemaField;
+
+ private CertificateValidity certificateValidityField;
+
+ private OverrideValidity certificateOverrideValidityField;
+
+ private subjectName subjectNameInfoField;
+
+ private Extension[] extensionsField;
+
+ private PrivateKeyInfo privateKeyAttributesField;
+
+ private ClientPolicy clientPolicyField;
+
+ private SystemInformation systemInfoField;
+
+ private RAPolicy rAPolicyField;
+
+ private SeatInfoType seatIdInfoField;
+
+ private ApplicationInstructionsType applicationInstructionsField;
+
+ private string deploymentModeField;
+
+ private string statusField;
+
+ private MigrationOIDCollection migrationOIDsField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public int policySchema {
+ get {
+ return this.policySchemaField;
+ }
+ set {
+ this.policySchemaField = value;
+ this.RaisePropertyChanged("policySchema");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public CertificateValidity certificateValidity {
+ get {
+ return this.certificateValidityField;
+ }
+ set {
+ this.certificateValidityField = value;
+ this.RaisePropertyChanged("certificateValidity");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=2)]
+ public OverrideValidity certificateOverrideValidity {
+ get {
+ return this.certificateOverrideValidityField;
+ }
+ set {
+ this.certificateOverrideValidityField = value;
+ this.RaisePropertyChanged("certificateOverrideValidity");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=3)]
+ public subjectName subjectNameInfo {
+ get {
+ return this.subjectNameInfoField;
+ }
+ set {
+ this.subjectNameInfoField = value;
+ this.RaisePropertyChanged("subjectNameInfo");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true, Order=4)]
+ [System.Xml.Serialization.XmlArrayItemAttribute(IsNullable=false)]
+ public Extension[] extensions {
+ get {
+ return this.extensionsField;
+ }
+ set {
+ this.extensionsField = value;
+ this.RaisePropertyChanged("extensions");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=5)]
+ public PrivateKeyInfo privateKeyAttributes {
+ get {
+ return this.privateKeyAttributesField;
+ }
+ set {
+ this.privateKeyAttributesField = value;
+ this.RaisePropertyChanged("privateKeyAttributes");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=6)]
+ public ClientPolicy clientPolicy {
+ get {
+ return this.clientPolicyField;
+ }
+ set {
+ this.clientPolicyField = value;
+ this.RaisePropertyChanged("clientPolicy");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=7)]
+ public SystemInformation systemInfo {
+ get {
+ return this.systemInfoField;
+ }
+ set {
+ this.systemInfoField = value;
+ this.RaisePropertyChanged("systemInfo");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=8)]
+ public RAPolicy rAPolicy {
+ get {
+ return this.rAPolicyField;
+ }
+ set {
+ this.rAPolicyField = value;
+ this.RaisePropertyChanged("rAPolicy");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=9)]
+ public SeatInfoType seatIdInfo {
+ get {
+ return this.seatIdInfoField;
+ }
+ set {
+ this.seatIdInfoField = value;
+ this.RaisePropertyChanged("seatIdInfo");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=10)]
+ public ApplicationInstructionsType applicationInstructions {
+ get {
+ return this.applicationInstructionsField;
+ }
+ set {
+ this.applicationInstructionsField = value;
+ this.RaisePropertyChanged("applicationInstructions");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=11)]
+ public string deploymentMode {
+ get {
+ return this.deploymentModeField;
+ }
+ set {
+ this.deploymentModeField = value;
+ this.RaisePropertyChanged("deploymentMode");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=12)]
+ public string status {
+ get {
+ return this.statusField;
+ }
+ set {
+ this.statusField = value;
+ this.RaisePropertyChanged("status");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=13)]
+ public MigrationOIDCollection migrationOIDs {
+ get {
+ return this.migrationOIDsField;
+ }
+ set {
+ this.migrationOIDsField = value;
+ this.RaisePropertyChanged("migrationOIDs");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=14)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class CertificateEnrollmentPolicy : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private int policyOIDReferenceField;
+
+ private int[] cAsField;
+
+ private Attributes attributesField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public int policyOIDReference {
+ get {
+ return this.policyOIDReferenceField;
+ }
+ set {
+ this.policyOIDReferenceField = value;
+ this.RaisePropertyChanged("policyOIDReference");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlArrayAttribute(Order=1)]
+ [System.Xml.Serialization.XmlArrayItemAttribute("cAReference", IsNullable=false)]
+ public int[] cAs {
+ get {
+ return this.cAsField;
+ }
+ set {
+ this.cAsField = value;
+ this.RaisePropertyChanged("cAs");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=2)]
+ public Attributes attributes {
+ get {
+ return this.attributesField;
+ }
+ set {
+ this.attributesField = value;
+ this.RaisePropertyChanged("attributes");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class Response : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string policyIDField;
+
+ private string policyFriendlyNameField;
+
+ private System.Nullable<uint> nextUpdateHoursField;
+
+ private bool policiesNotChangedField;
+
+ private CertificateEnrollmentPolicy[] policiesField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public string policyID {
+ get {
+ return this.policyIDField;
+ }
+ set {
+ this.policyIDField = value;
+ this.RaisePropertyChanged("policyID");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public string policyFriendlyName {
+ get {
+ return this.policyFriendlyNameField;
+ }
+ set {
+ this.policyFriendlyNameField = value;
+ this.RaisePropertyChanged("policyFriendlyName");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=2)]
+ public System.Nullable<uint> nextUpdateHours {
+ get {
+ return this.nextUpdateHoursField;
+ }
+ set {
+ this.nextUpdateHoursField = value;
+ this.RaisePropertyChanged("nextUpdateHours");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=3)]
+ public bool policiesNotChanged {
+ get {
+ return this.policiesNotChangedField;
+ }
+ set {
+ this.policiesNotChangedField = value;
+ this.RaisePropertyChanged("policiesNotChanged");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true, Order=4)]
+ [System.Xml.Serialization.XmlArrayItemAttribute("policy", IsNullable=false)]
+ public CertificateEnrollmentPolicy[] policies {
+ get {
+ return this.policiesField;
+ }
+ set {
+ this.policiesField = value;
+ this.RaisePropertyChanged("policies");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=5)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class RequestFilter : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string[] policyIDsField;
+
+ private System.Xml.XmlElement[] anyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true, Order=0)]
+ [System.Xml.Serialization.XmlArrayItemAttribute("oid", IsNullable=false)]
+ public string[] policyIDs {
+ get {
+ return this.policyIDsField;
+ }
+ set {
+ this.policyIDsField = value;
+ this.RaisePropertyChanged("policyIDs");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlAnyElementAttribute(Order=1)]
+ public System.Xml.XmlElement[] Any {
+ get {
+ return this.anyField;
+ }
+ set {
+ this.anyField = value;
+ this.RaisePropertyChanged("Any");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ /// <remarks/>
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34230")]
+ [System.SerializableAttribute()]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy")]
+ public partial class getPoliciesResponse : object, System.ComponentModel.INotifyPropertyChanged {
+
+ private string clientTransactionIDField;
+
+ private string serverTransactionIDField;
+
+ private Response responseField;
+
+ private CA[] cAsField;
+
+ private OID[] oIDsField;
+
+ private byte[] signedEnrollmentPolicyField;
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=0)]
+ public string clientTransactionID {
+ get {
+ return this.clientTransactionIDField;
+ }
+ set {
+ this.clientTransactionIDField = value;
+ this.RaisePropertyChanged("clientTransactionID");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=1)]
+ public string serverTransactionID {
+ get {
+ return this.serverTransactionIDField;
+ }
+ set {
+ this.serverTransactionIDField = value;
+ this.RaisePropertyChanged("serverTransactionID");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(Order=2)]
+ public Response response {
+ get {
+ return this.responseField;
+ }
+ set {
+ this.responseField = value;
+ this.RaisePropertyChanged("response");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true, Order=3)]
+ [System.Xml.Serialization.XmlArrayItemAttribute("cA", IsNullable=false)]
+ public CA[] cAs {
+ get {
+ return this.cAsField;
+ }
+ set {
+ this.cAsField = value;
+ this.RaisePropertyChanged("cAs");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true, Order=4)]
+ [System.Xml.Serialization.XmlArrayItemAttribute("oID", IsNullable=false)]
+ public OID[] oIDs {
+ get {
+ return this.oIDsField;
+ }
+ set {
+ this.oIDsField = value;
+ this.RaisePropertyChanged("oIDs");
+ }
+ }
+
+ /// <remarks/>
+ [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary", Order=5)]
+ public byte[] signedEnrollmentPolicy {
+ get {
+ return this.signedEnrollmentPolicyField;
+ }
+ set {
+ this.signedEnrollmentPolicyField = value;
+ this.RaisePropertyChanged("signedEnrollmentPolicy");
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ protected void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ [System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
+ public partial class requestPoliciesRequest {
+
+ [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy", Order=0)]
+ public ipn_sqlclr.Test.policyService.getPolicies getPolicies;
+
+ public requestPoliciesRequest() {
+ }
+
+ public requestPoliciesRequest(ipn_sqlclr.Test.policyService.getPolicies getPolicies) {
+ this.getPolicies = getPolicies;
+ }
+ }
+
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ [System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
+ public partial class requestPoliciesResponse {
+
+ [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://schemas.verisign.com/pkiservices/2009/07/policy", Order=0)]
+ public ipn_sqlclr.Test.policyService.getPoliciesResponse getPoliciesResponse;
+
+ public requestPoliciesResponse() {
+ }
+
+ public requestPoliciesResponse(ipn_sqlclr.Test.policyService.getPoliciesResponse getPoliciesResponse) {
+ this.getPoliciesResponse = getPoliciesResponse;
+ }
+ }
+
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+ public interface policyChannel : ipn_sqlclr.Test.policyService.policy, System.ServiceModel.IClientChannel {
+ }
+
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+ public partial class policyClient : System.ServiceModel.ClientBase<ipn_sqlclr.Test.policyService.policy>, ipn_sqlclr.Test.policyService.policy {
+
+ public policyClient() {
+ }
+
+ public policyClient(string endpointConfigurationName) :
+ base(endpointConfigurationName) {
+ }
+
+ public policyClient(string endpointConfigurationName, string remoteAddress) :
+ base(endpointConfigurationName, remoteAddress) {
+ }
+
+ public policyClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
+ base(endpointConfigurationName, remoteAddress) {
+ }
+
+ public policyClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
+ base(binding, remoteAddress) {
+ }
+
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ ipn_sqlclr.Test.policyService.requestPoliciesResponse ipn_sqlclr.Test.policyService.policy.requestPolicies(ipn_sqlclr.Test.policyService.requestPoliciesRequest request) {
+ return base.Channel.requestPolicies(request);
+ }
+
+ public ipn_sqlclr.Test.policyService.getPoliciesResponse requestPolicies(ipn_sqlclr.Test.policyService.getPolicies getPolicies) {
+ ipn_sqlclr.Test.policyService.requestPoliciesRequest inValue = new ipn_sqlclr.Test.policyService.requestPoliciesRequest();
+ inValue.getPolicies = getPolicies;
+ ipn_sqlclr.Test.policyService.requestPoliciesResponse retVal = ((ipn_sqlclr.Test.policyService.policy)(this)).requestPolicies(inValue);
+ return retVal.getPoliciesResponse;
+ }
+ }
+}
diff --git a/unit-tests/ipn_sqlclr.Test/Service References/policyService/Reference.svcmap b/unit-tests/ipn_sqlclr.Test/Service References/policyService/Reference.svcmap
new file mode 100644
index 0000000..f961e0d
--- /dev/null
+++ b/unit-tests/ipn_sqlclr.Test/Service References/policyService/Reference.svcmap
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ReferenceGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ID="00460f42-a971-4c43-ad3b-382fdbd5b937" xmlns="urn:schemas-microsoft-com:xml-wcfservicemap">
+ <ClientOptions>
+ <GenerateAsynchronousMethods>false</GenerateAsynchronousMethods>
+ <EnableDataBinding>true</EnableDataBinding>
+ <ExcludedTypes />
+ <ImportXmlTypes>false</ImportXmlTypes>
+ <GenerateInternalTypes>false</GenerateInternalTypes>
+ <GenerateMessageContracts>false</GenerateMessageContracts>
+ <NamespaceMappings />
+ <CollectionMappings />
+ <GenerateSerializableTypes>true</GenerateSerializableTypes>
+ <Serializer>Auto</Serializer>
+ <UseSerializerForFaults>true</UseSerializerForFaults>
+ <ReferenceAllAssemblies>true</ReferenceAllAssemblies>
+ <ReferencedAssemblies />
+ <ReferencedDataContractTypes />
+ <ServiceContractMappings />
+ </ClientOptions>
+ <MetadataSources>
+ <MetadataSource Address="C:\Users\Youra\Documents\GitHub\my-vmprotect\tagg\CertificateEnrollmentPolicy.wsdl" Protocol="file" SourceId="1" />
+ </MetadataSources>
+ <Metadata>
+ <MetadataFile FileName="CertificateEnrollmentPolicy.xsd" MetadataType="Schema" ID="6090e094-b1b5-4dff-b775-2fd0eb92b73b" SourceId="1" SourceUrl="file:///C:/Users/Youra/Documents/GitHub/my-vmprotect/tagg/CertificateEnrollmentPolicy.xsd" />
+ <MetadataFile FileName="CertificateEnrollmentPolicy.wsdl" MetadataType="Wsdl" ID="f6e85f3b-a650-4d04-ba29-44d72553b97e" SourceId="1" SourceUrl="file:///C:/Users/Youra/Documents/GitHub/my-vmprotect/tagg/CertificateEnrollmentPolicy.wsdl" />
+ </Metadata>
+ <Extensions>
+ <ExtensionFile FileName="configuration91.svcinfo" Name="configuration91.svcinfo" />
+ <ExtensionFile FileName="configuration.svcinfo" Name="configuration.svcinfo" />
+ </Extensions>
+</ReferenceGroup> \ No newline at end of file
diff --git a/unit-tests/ipn_sqlclr.Test/Service References/policyService/configuration.svcinfo b/unit-tests/ipn_sqlclr.Test/Service References/policyService/configuration.svcinfo
new file mode 100644
index 0000000..e99827d
--- /dev/null
+++ b/unit-tests/ipn_sqlclr.Test/Service References/policyService/configuration.svcinfo
@@ -0,0 +1,11 @@
+п»ї<?xml version="1.0" encoding="utf-8"?>
+<configurationSnapshot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:schemas-microsoft-com:xml-wcfconfigurationsnapshot">
+ <behaviors />
+ <bindings>
+ <binding digest="System.ServiceModel.Configuration.BasicHttpBindingElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data name=&quot;requestPoliciesServiceSOAP&quot;&gt;&lt;security mode=&quot;Transport&quot; /&gt;&lt;/Data&gt;" bindingType="basicHttpBinding" name="requestPoliciesServiceSOAP" />
+ <binding digest="System.ServiceModel.Configuration.BasicHttpBindingElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data name=&quot;requestPoliciesServiceSOAP1&quot; /&gt;" bindingType="basicHttpBinding" name="requestPoliciesServiceSOAP1" />
+ </bindings>
+ <endpoints>
+ <endpoint normalizedDigest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;https://pki-ws.symauth.com/pki-ws/policyService&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;requestPoliciesServiceSOAP&quot; contract=&quot;policyService.policy&quot; name=&quot;requestPoliciesServiceSOAP&quot; /&gt;" digest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;https://pki-ws.symauth.com/pki-ws/policyService&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;requestPoliciesServiceSOAP&quot; contract=&quot;policyService.policy&quot; name=&quot;requestPoliciesServiceSOAP&quot; /&gt;" contractName="policyService.policy" name="requestPoliciesServiceSOAP" />
+ </endpoints>
+</configurationSnapshot> \ No newline at end of file
diff --git a/unit-tests/ipn_sqlclr.Test/Service References/policyService/configuration91.svcinfo b/unit-tests/ipn_sqlclr.Test/Service References/policyService/configuration91.svcinfo
new file mode 100644
index 0000000..e6a1487
--- /dev/null
+++ b/unit-tests/ipn_sqlclr.Test/Service References/policyService/configuration91.svcinfo
@@ -0,0 +1,310 @@
+<?xml version="1.0" encoding="utf-8"?>
+<SavedWcfConfigurationInformation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="9.1" CheckSum="sdPdnbX35IphatM6VrabzGivuXc=">
+ <bindingConfigurations>
+ <bindingConfiguration bindingType="basicHttpBinding" name="requestPoliciesServiceSOAP">
+ <properties>
+ <property path="/name" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>requestPoliciesServiceSOAP</serializedValue>
+ </property>
+ <property path="/closeTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/openTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/receiveTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/sendTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/allowCookies" isComplexType="false" isExplicitlyDefined="true" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/bypassProxyOnLocal" isComplexType="false" isExplicitlyDefined="true" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/hostNameComparisonMode" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.HostNameComparisonMode, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>StrongWildcard</serializedValue>
+ </property>
+ <property path="/maxBufferPoolSize" isComplexType="false" isExplicitlyDefined="true" clrType="System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/maxBufferSize" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>65536</serializedValue>
+ </property>
+ <property path="/maxReceivedMessageSize" isComplexType="false" isExplicitlyDefined="true" clrType="System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/proxyAddress" isComplexType="false" isExplicitlyDefined="false" clrType="System.Uri, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/readerQuotas" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement</serializedValue>
+ </property>
+ <property path="/readerQuotas/maxDepth" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>0</serializedValue>
+ </property>
+ <property path="/readerQuotas/maxStringContentLength" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>0</serializedValue>
+ </property>
+ <property path="/readerQuotas/maxArrayLength" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>0</serializedValue>
+ </property>
+ <property path="/readerQuotas/maxBytesPerRead" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>0</serializedValue>
+ </property>
+ <property path="/readerQuotas/maxNameTableCharCount" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>0</serializedValue>
+ </property>
+ <property path="/textEncoding" isComplexType="false" isExplicitlyDefined="false" clrType="System.Text.Encoding, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.Text.UTF8Encoding</serializedValue>
+ </property>
+ <property path="/transferMode" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.TransferMode, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>Buffered</serializedValue>
+ </property>
+ <property path="/useDefaultWebProxy" isComplexType="false" isExplicitlyDefined="true" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/messageEncoding" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.WSMessageEncoding, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>Text</serializedValue>
+ </property>
+ <property path="/security" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.BasicHttpSecurityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.BasicHttpSecurityElement</serializedValue>
+ </property>
+ <property path="/security/mode" isComplexType="false" isExplicitlyDefined="true" clrType="System.ServiceModel.BasicHttpSecurityMode, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>Transport</serializedValue>
+ </property>
+ <property path="/security/transport" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.HttpTransportSecurityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.HttpTransportSecurityElement</serializedValue>
+ </property>
+ <property path="/security/transport/clientCredentialType" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.HttpClientCredentialType, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>None</serializedValue>
+ </property>
+ <property path="/security/transport/proxyCredentialType" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.HttpProxyCredentialType, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>None</serializedValue>
+ </property>
+ <property path="/security/transport/extendedProtectionPolicy" isComplexType="true" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement</serializedValue>
+ </property>
+ <property path="/security/transport/extendedProtectionPolicy/policyEnforcement" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.PolicyEnforcement, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>Never</serializedValue>
+ </property>
+ <property path="/security/transport/extendedProtectionPolicy/protectionScenario" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.ProtectionScenario, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>TransportSelected</serializedValue>
+ </property>
+ <property path="/security/transport/extendedProtectionPolicy/customServiceNames" isComplexType="true" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.Configuration.ServiceNameElementCollection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>(Collection)</serializedValue>
+ </property>
+ <property path="/security/transport/realm" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/security/message" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.BasicHttpMessageSecurityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.BasicHttpMessageSecurityElement</serializedValue>
+ </property>
+ <property path="/security/message/clientCredentialType" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.BasicHttpMessageCredentialType, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>UserName</serializedValue>
+ </property>
+ <property path="/security/message/algorithmSuite" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.Security.SecurityAlgorithmSuite, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>Default</serializedValue>
+ </property>
+ </properties>
+ </bindingConfiguration>
+ <bindingConfiguration bindingType="basicHttpBinding" name="requestPoliciesServiceSOAP1">
+ <properties>
+ <property path="/name" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>requestPoliciesServiceSOAP1</serializedValue>
+ </property>
+ <property path="/closeTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/openTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/receiveTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/sendTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/allowCookies" isComplexType="false" isExplicitlyDefined="true" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/bypassProxyOnLocal" isComplexType="false" isExplicitlyDefined="true" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/hostNameComparisonMode" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.HostNameComparisonMode, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>StrongWildcard</serializedValue>
+ </property>
+ <property path="/maxBufferPoolSize" isComplexType="false" isExplicitlyDefined="true" clrType="System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/maxBufferSize" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>65536</serializedValue>
+ </property>
+ <property path="/maxReceivedMessageSize" isComplexType="false" isExplicitlyDefined="true" clrType="System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/proxyAddress" isComplexType="false" isExplicitlyDefined="false" clrType="System.Uri, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/readerQuotas" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement</serializedValue>
+ </property>
+ <property path="/readerQuotas/maxDepth" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>0</serializedValue>
+ </property>
+ <property path="/readerQuotas/maxStringContentLength" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>0</serializedValue>
+ </property>
+ <property path="/readerQuotas/maxArrayLength" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>0</serializedValue>
+ </property>
+ <property path="/readerQuotas/maxBytesPerRead" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>0</serializedValue>
+ </property>
+ <property path="/readerQuotas/maxNameTableCharCount" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>0</serializedValue>
+ </property>
+ <property path="/textEncoding" isComplexType="false" isExplicitlyDefined="false" clrType="System.Text.Encoding, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.Text.UTF8Encoding</serializedValue>
+ </property>
+ <property path="/transferMode" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.TransferMode, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>Buffered</serializedValue>
+ </property>
+ <property path="/useDefaultWebProxy" isComplexType="false" isExplicitlyDefined="true" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/messageEncoding" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.WSMessageEncoding, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>Text</serializedValue>
+ </property>
+ <property path="/security" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.BasicHttpSecurityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.BasicHttpSecurityElement</serializedValue>
+ </property>
+ <property path="/security/mode" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.BasicHttpSecurityMode, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>None</serializedValue>
+ </property>
+ <property path="/security/transport" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.HttpTransportSecurityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.HttpTransportSecurityElement</serializedValue>
+ </property>
+ <property path="/security/transport/clientCredentialType" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.HttpClientCredentialType, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>None</serializedValue>
+ </property>
+ <property path="/security/transport/proxyCredentialType" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.HttpProxyCredentialType, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>None</serializedValue>
+ </property>
+ <property path="/security/transport/extendedProtectionPolicy" isComplexType="true" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement</serializedValue>
+ </property>
+ <property path="/security/transport/extendedProtectionPolicy/policyEnforcement" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.PolicyEnforcement, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>Never</serializedValue>
+ </property>
+ <property path="/security/transport/extendedProtectionPolicy/protectionScenario" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.ProtectionScenario, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>TransportSelected</serializedValue>
+ </property>
+ <property path="/security/transport/extendedProtectionPolicy/customServiceNames" isComplexType="true" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.Configuration.ServiceNameElementCollection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>(Collection)</serializedValue>
+ </property>
+ <property path="/security/transport/realm" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/security/message" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.BasicHttpMessageSecurityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.BasicHttpMessageSecurityElement</serializedValue>
+ </property>
+ <property path="/security/message/clientCredentialType" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.BasicHttpMessageCredentialType, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>UserName</serializedValue>
+ </property>
+ <property path="/security/message/algorithmSuite" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.Security.SecurityAlgorithmSuite, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>Default</serializedValue>
+ </property>
+ </properties>
+ </bindingConfiguration>
+ </bindingConfigurations>
+ <endpoints>
+ <endpoint name="requestPoliciesServiceSOAP" contract="policyService.policy" bindingType="basicHttpBinding" address="https://pki-ws.symauth.com/pki-ws/policyService" bindingConfiguration="requestPoliciesServiceSOAP">
+ <properties>
+ <property path="/address" isComplexType="false" isExplicitlyDefined="true" clrType="System.Uri, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>https://pki-ws.symauth.com/pki-ws/policyService</serializedValue>
+ </property>
+ <property path="/behaviorConfiguration" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/binding" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>basicHttpBinding</serializedValue>
+ </property>
+ <property path="/bindingConfiguration" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>requestPoliciesServiceSOAP</serializedValue>
+ </property>
+ <property path="/contract" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>policyService.policy</serializedValue>
+ </property>
+ <property path="/headers" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.AddressHeaderCollectionElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.AddressHeaderCollectionElement</serializedValue>
+ </property>
+ <property path="/headers/headers" isComplexType="false" isExplicitlyDefined="true" clrType="System.ServiceModel.Channels.AddressHeaderCollection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>&lt;Header /&gt;</serializedValue>
+ </property>
+ <property path="/identity" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.IdentityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.IdentityElement</serializedValue>
+ </property>
+ <property path="/identity/userPrincipalName" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.UserPrincipalNameElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.UserPrincipalNameElement</serializedValue>
+ </property>
+ <property path="/identity/userPrincipalName/value" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/identity/servicePrincipalName" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.ServicePrincipalNameElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.ServicePrincipalNameElement</serializedValue>
+ </property>
+ <property path="/identity/servicePrincipalName/value" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/identity/dns" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.DnsElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.DnsElement</serializedValue>
+ </property>
+ <property path="/identity/dns/value" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/identity/rsa" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.RsaElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.RsaElement</serializedValue>
+ </property>
+ <property path="/identity/rsa/value" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/identity/certificate" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.CertificateElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.CertificateElement</serializedValue>
+ </property>
+ <property path="/identity/certificate/encodedValue" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/identity/certificateReference" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.CertificateReferenceElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>System.ServiceModel.Configuration.CertificateReferenceElement</serializedValue>
+ </property>
+ <property path="/identity/certificateReference/storeName" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Cryptography.X509Certificates.StoreName, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>My</serializedValue>
+ </property>
+ <property path="/identity/certificateReference/storeLocation" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Cryptography.X509Certificates.StoreLocation, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>LocalMachine</serializedValue>
+ </property>
+ <property path="/identity/certificateReference/x509FindType" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Cryptography.X509Certificates.X509FindType, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>FindBySubjectDistinguishedName</serializedValue>
+ </property>
+ <property path="/identity/certificateReference/findValue" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/identity/certificateReference/isChainIncluded" isComplexType="false" isExplicitlyDefined="false" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>False</serializedValue>
+ </property>
+ <property path="/name" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue>requestPoliciesServiceSOAP</serializedValue>
+ </property>
+ <property path="/kind" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ <property path="/endpointConfiguration" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <serializedValue />
+ </property>
+ </properties>
+ </endpoint>
+ </endpoints>
+</SavedWcfConfigurationInformation> \ No newline at end of file
diff --git a/unit-tests/ipn_sqlclr.Test/Service References/policyService/ipn_sqlclr.Test.policyService.getPoliciesResponse.datasource b/unit-tests/ipn_sqlclr.Test/Service References/policyService/ipn_sqlclr.Test.policyService.getPoliciesResponse.datasource
new file mode 100644
index 0000000..a7bdd87
--- /dev/null
+++ b/unit-tests/ipn_sqlclr.Test/Service References/policyService/ipn_sqlclr.Test.policyService.getPoliciesResponse.datasource
@@ -0,0 +1,10 @@
+п»ї<?xml version="1.0" encoding="utf-8"?>
+<!--
+ This file is automatically generated by Visual Studio .Net. It is
+ used to store generic object data source configuration information.
+ Renaming the file extension or editing the content of this file may
+ cause the file to be unrecognizable by the program.
+-->
+<GenericObjectDataSource DisplayName="getPoliciesResponse" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
+ <TypeInfo>ipn_sqlclr.Test.policyService.getPoliciesResponse, Service References.policyService.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
+</GenericObjectDataSource> \ No newline at end of file
diff --git a/unit-tests/ipn_sqlclr.Test/TaggantWebTest.cs b/unit-tests/ipn_sqlclr.Test/TaggantWebTest.cs
new file mode 100644
index 0000000..970048f
--- /dev/null
+++ b/unit-tests/ipn_sqlclr.Test/TaggantWebTest.cs
@@ -0,0 +1,129 @@
+п»їusing System.Collections.Generic;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+
+namespace ipn_sqlclr.Test
+{
+ /// <summary>
+ /// Summary description for TaggantWebTest
+ /// </summary>
+ [TestClass]
+ public class TaggantWebTest
+ {
+ public TaggantWebTest()
+ {
+ //
+ // TODO: Add constructor logic here
+ //
+ }
+
+ private TestContext testContextInstance;
+
+ /// <summary>
+ ///Gets or sets the test context which provides
+ ///information about and functionality for the current test run.
+ ///</summary>
+ public TestContext TestContext
+ {
+ get { return testContextInstance; }
+ set { testContextInstance = value; }
+ }
+
+ #region Additional test attributes
+
+ //
+ // You can use the following additional attributes as you write your tests:
+ //
+ // Use ClassInitialize to run code before running the first test in the class
+ // [ClassInitialize()]
+ // public static void MyClassInitialize(TestContext testContext) { }
+ //
+ // Use ClassCleanup to run code after all tests in a class have run
+ // [ClassCleanup()]
+ // public static void MyClassCleanup() { }
+ //
+ // Use TestInitialize to run code before running each test
+ // [TestInitialize()]
+ // public void MyTestInitialize() { }
+ //
+ // Use TestCleanup to run code after each test has run
+ // [TestCleanup()]
+ // public void MyTestCleanup() { }
+ //
+
+ #endregion
+
+ [TestMethod]
+ public void PK()
+ {
+ string s = (string) UserDefinedFunctions.TaggantPrivateKeyGenerateNew();
+
+ }
+
+ [TestMethod]
+ public void WS()
+ {
+ var tc = new TaggantConfig()
+ {
+ { "CertificateProfileOID", "2.16.840.1.113733.1.16.1.3.1.4.1.38113944" },
+ { "ClientCertificate", "Registration Authority 1409598283849" },
+ { "CsrAlgorithm", "MD5withRSA" },
+ { "CsrSubject", "O=VMPSoft,OU=Build Server,E=support@vmpsoft.com,L=Yekaterinburg,ST=Ural,C=RU,CN=support@vmpsoft.com" },
+ { "EnrollmentUrl", "https://pki-ws.symauth.com/pki-ws/enrollmentService" },
+ { "EnrollVersion", "2.0" },
+ { "PolicyUrl", "https://pki-ws.symauth.com/pki-ws/policyService" },
+ { "PolicyVersion", "2.0" },
+ };
+ tc.ClientCertificate = UserDefinedFunctions.LocateCertificate(tc["ClientCertificate"]);
+ var log = new List<LogItem>();
+ TaggantWebService.GetPolicies(tc, log);
+
+ }
+ [TestMethod]
+ public void WS2()
+ {
+ var tc = new TaggantConfig()
+ {
+ { "CertificateProfileOid", "2.16.840.1.113733.1.16.1.3.1.4.1.38113944" },
+ { "ClientCertificate", "Registration Authority 1409598283849" },
+ { "CsrAlgorithm", "MD5withRSA" },
+ { "CsrSubject", "O=VMPSoft,OU=Build Server,E=support@vmpsoft.com,L=Yekaterinburg,ST=Ural,C=RU,CN=support@vmpsoft.com" },
+ { "EnrollmentUrl", "https://pki-ws.symauth.com/pki-ws/enrollmentService" },
+ { "EnrollVersion", "2.0" },
+ { "PolicyUrl", "https://pki-ws.symauth.com/pki-ws/policyService" },
+ { "PolicyVersion", "2.0" },
+ };
+ tc.ClientCertificate = UserDefinedFunctions.LocateCertificate(tc["ClientCertificate"]);
+ var log = new List<LogItem>();
+ TaggantWebService.CertRequestNew(tc, "ipn2217", "sqhunter123@mail.ru", "-----BEGIN RSA PRIVATE KEY-----\n" +
+ "MIIEpAIBAAKCAQEAhjXJd3dMP5BE1mAXh3sAIiK9xUdw3R7lgRA0PtwIDdA1UX5v\n" +
+ "QHAWk7d5HwDB3V3T1WBRW3tFyjq7YRPB6QM0d2qPi+rpDsT6QlQSCAcVgdyiS1KW" +
+ "4OYVlVq2vjzVOeFhlgyaSRP06GGNYXBAL9e2yky7hs45OCdMGErLNCJ+Ja97wPtv" +
+ "Hk03C3ml9kvHegVecMp+5piy5fni+UsJ7toPZFo7HAbB23dc0Rfxj8BiGTM08yuQ" +
+ "U6nmpjDrtRrOyzIJDIriAKMJ4eTc8rF/y9uG3/ibwmkSH0MtYIvSfyim43ofL8rT" +
+ "ijhsO0yiMDMSAJyuAJCZjsCAYTMnrsas8c1P9QIDAQABAoIBAC2B43RcwT/0XUML" +
+ "hi7sKBlrCknwdXak2VEv+2ctGJYGeW3On06MMzuXRLycdx/mhsOdSzjnzbxKueqq" +
+ "1l96NLohKddZqfjWFb2T4CFUtZg5BdbghERx//OKtNhArFRZ9cr5Lv+EgtCg812M" +
+ "wFb4oARsjFGjb4d427aI9eoRoBCKt9A9CfqwxHyvclgtIG3W7FazvZ8s1KXhTh4i" +
+ "N3HHSUkxaADKl6uO4fclq+/tX1mffitIfOxlbZHUsOE1y8tKh8e0onWQ0l2F4aio" +
+ "SbBhgNo6QiihnVpfpYKn+fMqrZ3qDaky7r94avR7KHneMIwJG5diBrpf5+36xzi6" +
+ "0Jzy+WkCgYEAzltVepiWZGvmvofGO+PwbVtSYQQt1htE5bnfL4fwPYjSgPiboSTw" +
+ "5LBVHQWcaGqmNBrmnE1r0vk4Dam/a/Ok2M3+lZXzx3nJTGTjd3PzFP83WnPdplkE" +
+ "SHau7/EYc8tWGtEGzzUJiLT12n7EFxk8YASpL1znFeKhuDsVgJBkhHsCgYEApn88" +
+ "c5G7iE1GYCTSclKyU9avBJNiXNdbSy0fnizGQaSp1f3hCtiYbE7Yf6QXfu9gVKf+" +
+ "FD9a7HJa04QgRr5RmBV8ToLWzBdTZoud2fqO61lhePBQC+d1SyO5BwOzD9vk8BSR" +
+ "vmaoQoJf8GSzrmhcABo0zkD6uomYohO0wI4Q6k8CgYEAtBpU9YYdpJHkNyCrbHQZ" +
+ "0Ggm8xPBqZ/tNw9N8t8TV7GGABh7RF7IfOBFuOm/xAZo/wsHgR21YNIxEQO5VU+1" +
+ "7Z+EdiwFM3FgtnNLcGNbolTJjAGaT2hb657iOfrT26R5hzguWESzCITgGw4OuRZG" +
+ "cos+2l6cNaayfOfccXQUtucCgYBa+6qoKNoG6NttTJHnwUMLx4RKhtO4kkKkORtP" +
+ "D36jfn0EoECq8aORhCCQ17WzOtI0ULzqiZiBHxh8/3W30ua5qfwM1zjTvGdp4R+4" +
+ "b1BMUcKPGRtU9f3Futawe5gNMYfQnhzqpCSMe7w7nHwH8aVctPVoRF//MZPD9erP" +
+ "UpLxxwKBgQC121tfFNQwNuhQjdz/AD/IjkyDzhAKpOuVrbeFq+Hl31LZN/YBNJbX" +
+ "7jzQuQ4Pn+D+7ID4s/RVOg/zNvQ9AbWgDmfQ5+7RoEoooM2U0l6DzbVp6MaSw2mT" +
+ "l6VgW2QubgrqIlt9Rk+zX6pSlN8LDjosYEbnzOhZ5B0Sc20RSkUcjg==\n" +
+ "-----END RSA PRIVATE KEY-----", log);
+
+ }
+
+ }
+}
diff --git a/unit-tests/ipn_sqlclr.Test/VmpLicenseKeyTest.cs b/unit-tests/ipn_sqlclr.Test/VmpLicenseKeyTest.cs
new file mode 100644
index 0000000..8bf701c
--- /dev/null
+++ b/unit-tests/ipn_sqlclr.Test/VmpLicenseKeyTest.cs
@@ -0,0 +1,73 @@
+п»їusing System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace ipn_sqlclr.Test
+{
+ [TestClass]
+ public class VmpLicenseKeyTest
+ {
+ /*[TestMethod] не проходит почему-то
+ public void TestRsa()
+ {
+ var r = new Random();
+ var data1 = new byte[3072 / 8];
+ for (int i = 0; i < data1.Length; i++) data1[i] = (byte)r.Next(256);
+
+ var encr1 = Rsa.Encrypt(data1);
+ var decr1 = Rsa.Decrypt(encr1);
+
+ Assert.AreNotEqual(data1, encr1);
+ Assert.AreEqual(data1, decr1);
+ }*/
+
+ [TestMethod]
+ public void TestGenerateAndParseKey()
+ {
+ const int productId = 5;
+ const string name = "Рван ПетровААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААААА";
+ const string mail = "petrov@mail.ruРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђРђ";
+ var maxBuild = new DateTime(2015, 12, 28);
+ var key = Keygen.GenerateKey(productId, name, mail, maxBuild);
+
+ int productId1;
+ string name1, mail1;
+ DateTime maxBuild1;
+ Keygen.ParseKey(key, out productId1, out name1, out mail1, out maxBuild1);
+
+ Assert.AreEqual(productId, productId1);
+ Assert.AreEqual(name, name1);
+ Assert.AreEqual(mail, mail1);
+ Assert.AreEqual(maxBuild, maxBuild1);
+
+ Keygen.ParseKey("FgeTRyB93RJeABJN83qKo7mTEvXHGHwYXmZ6pGY5o1X09bc8fmmebq1mryX5yHUWb6F+cauzsLxUyG+uTQBT9zC31EJPQqG9YgaRbOPPS9A7u1HXZA8x491ew0lDKJISy8TYNsjTJ2vB903jW+/A/UVc2+cgDCF3eqztkvYBEas6Y40Hj9A2ylJVYsYWq41RCZyDcXZtlbnuk8W2CDBAk+PGZeUPjEq/oasnTCeKdkO4NY2QVrFzvC/msT+7FWAaBNwe5OQYZLCH875qFVw0H2B9xcnVuIAHAYD00H0Hzk9sf/jAGx4l5CS8FQ4tshZfEllF6CcwVQuRdGz07gQWAQ=="
+ ,out productId1, out name1, out mail1, out maxBuild1);
+ }
+
+ [TestMethod]
+ public void TestParseOldKey()
+ {
+ const int productId = -1;
+ const string name = "道恭 陈";
+ const string mail = "sales@sky-deep.com";
+ var maxBuild = new DateTime(2015, 12, 13);
+ const string key = "m/j+Km6Y7Kb5AgV0pfLr/Bmw3z9EP/SNv9mawGK0PK8mXWMcJijSzfMbVakJa8ctaZVaNceeanc6" +
+ "FuurAcyDEpppwS71/t6SoI6Kxc/BUmcHjLlfrWhxk5CrQqFVqyQ+liZEhglHuCE8GRwlPgm60JVv" +
+ "hCsQBEDeIywTp2GujhjhGra7ojML/guuhRS6W1ILSSkfZriDuCFkkStLgi9gT8GGwX1GUdaXz7Wn" +
+ "IxrcSYt5OLuPOcPULPUgVr1tB0YopWt/7g3g9jvRxVTThBxcAr+IoIf8RtaTTPIMDae9OZTDL6Pv" +
+ "p10cUj1HGC1kB8whLWyGdqbhpyg53vUc4Y7FdHe3zUltZA3c3p4/DdZwrU+jrMC/SdzJVuo1MM4p" +
+ "ZefRwH2f1MYKCUT2zn67f87Sgo2LMmSjWnaORHxrUtskEyguRYcgh0dy6RApI07ZXrK06ZCQu9Ns" +
+ "zdN3vkxo+NV9clNmVffE7GfRDlcmczvffGcuEUYN59juPnp/vMhFpH1r";
+
+ int productId1;
+ string name1, mail1;
+ DateTime maxBuild1;
+ Keygen.ParseKey(key, out productId1, out name1, out mail1, out maxBuild1);
+
+ Assert.AreEqual(productId, productId1);
+ Assert.AreEqual(name, name1);
+ Assert.AreEqual(mail, mail1);
+ Assert.AreEqual(maxBuild, maxBuild1);
+ }
+
+ }
+}
diff --git a/unit-tests/ipn_sqlclr.Test/app.config b/unit-tests/ipn_sqlclr.Test/app.config
new file mode 100644
index 0000000..ce55b93
--- /dev/null
+++ b/unit-tests/ipn_sqlclr.Test/app.config
@@ -0,0 +1,3 @@
+п»ї<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+</configuration>
diff --git a/unit-tests/ipn_sqlclr.Test/ipn_sqlclr.Test.csproj b/unit-tests/ipn_sqlclr.Test/ipn_sqlclr.Test.csproj
new file mode 100644
index 0000000..25b74e1
--- /dev/null
+++ b/unit-tests/ipn_sqlclr.Test/ipn_sqlclr.Test.csproj
@@ -0,0 +1,128 @@
+п»ї<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{F90215BE-45F4-422B-AE75-A2E7DDAC1758}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ipn_sqlclr.Test</RootNamespace>
+ <AssemblyName>ipn_sqlclr.Test</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
+ <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
+ <IsCodedUITest>False</IsCodedUITest>
+ <TestProjectType>UnitTest</TestProjectType>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Runtime.Serialization" />
+ <Reference Include="System.Security" />
+ <Reference Include="System.ServiceModel" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <Choose>
+ <When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+ </ItemGroup>
+ </When>
+ <Otherwise>
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
+ </ItemGroup>
+ </Otherwise>
+ </Choose>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Service References\policyService\Reference.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Reference.svcmap</DependentUpon>
+ </Compile>
+ <Compile Include="TaggantWebTest.cs" />
+ <Compile Include="VmpLicenseKeyTest.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\utils\ipn_sqlclr\ipn_sqlclr.sqlproj">
+ <Project>{046364af-635b-4f62-9c8c-d3866b8f622f}</Project>
+ <Name>ipn_sqlclr</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <WCFMetadata Include="Service References\" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="Service References\policyService\CertificateEnrollmentPolicy.wsdl" />
+ <None Include="Service References\policyService\CertificateEnrollmentPolicy.xsd">
+ <SubType>Designer</SubType>
+ </None>
+ <None Include="Service References\policyService\ipn_sqlclr.Test.policyService.getPoliciesResponse.datasource">
+ <DependentUpon>Reference.svcmap</DependentUpon>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <WCFMetadataStorage Include="Service References\policyService\" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Service References\policyService\configuration91.svcinfo" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Service References\policyService\configuration.svcinfo" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Service References\policyService\Reference.svcmap">
+ <Generator>WCF Proxy Generator</Generator>
+ <LastGenOutput>Reference.cs</LastGenOutput>
+ </None>
+ </ItemGroup>
+ <Choose>
+ <When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ </ItemGroup>
+ </When>
+ </Choose>
+ <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/unit-tests/lin_unit-tests.mak b/unit-tests/lin_unit-tests.mak
new file mode 100644
index 0000000..8d9723c
--- /dev/null
+++ b/unit-tests/lin_unit-tests.mak
@@ -0,0 +1,16 @@
+SOURCES := core_tests.cc files_tests.cc intel_tests.cc il_tests.cc macfile_tests.cc pefile_tests.cc elffile_tests.cc test1.cc ../third-party/lzma/LzmaDecode.cc
+
+PROJECT := unit.Tests
+TARGET := $(PROJECT)
+BIN_DIR := ../bin/$(ARCH_DIR)/$(CFG_DIR)
+TMP_DIR := ../tmp/lin/$(PROJECT)/$(ARCH_DIR)/TESTS
+PCH_DIR := $(TMP_DIR)/$(PROJECT).gch
+DEFINES := $(CONFIG) -D TIXML_USE_STL -D _CONSOLE -D FFI_BUILDING
+LFLAGS :=
+LIBS = $(SDK_LIBS) -Wl,--no-as-needed -L../bin -lVMProtectSDK$(ARCH_DIR) -ldl -Wl,--as-needed
+OBJCOMP := ../bin/$(ARCH_DIR)/Release/gtests.a ../bin/$(ARCH_DIR)/$(CFG_DIR)/core.a ../bin/$(ARCH_DIR)/invariant_core.a ../third-party/libffi/libffi$(ARCH_DIR).a -lcrypto -lpthread
+DYLIBS :=
+INCFLAGS := -I ../third-party/gmock/include/ -I ../third-party/gtest/include/ -I ../third-party/gmock/ -I ../third-party/gtest/
+
+include ../lin_common.mak
+include ../gnu_simple.mak
diff --git a/unit-tests/lin_unit-tests32.mak b/unit-tests/lin_unit-tests32.mak
new file mode 100644
index 0000000..c11cbbd
--- /dev/null
+++ b/unit-tests/lin_unit-tests32.mak
@@ -0,0 +1,3 @@
+ARCH := i386-linux-gnu
+ARCH_DIR := 32
+include lin_unit-tests.mak
diff --git a/unit-tests/lin_unit-tests64.mak b/unit-tests/lin_unit-tests64.mak
new file mode 100644
index 0000000..14c8e42
--- /dev/null
+++ b/unit-tests/lin_unit-tests64.mak
@@ -0,0 +1,3 @@
+ARCH := x86_64-linux-gnu
+ARCH_DIR := 64
+include lin_unit-tests.mak
diff --git a/unit-tests/mac_unit-tests.mak b/unit-tests/mac_unit-tests.mak
new file mode 100644
index 0000000..f86aef9
--- /dev/null
+++ b/unit-tests/mac_unit-tests.mak
@@ -0,0 +1,16 @@
+SOURCES := core_tests.cc files_tests.cc intel_tests.cc il_tests.cc macfile_tests.cc pefile_tests.cc elffile_tests.cc test1.cc ../third-party/lzma/LzmaDecode.cc
+
+PROJECT := unit.Tests
+TARGET := $(PROJECT)
+BIN_DIR := ../bin/$(ARCH_DIR)/$(CFG_DIR)
+TMP_DIR := ../tmp/mac/$(PROJECT)/$(ARCH_DIR)/TESTS
+PCH_DIR := $(TMP_DIR)/$(PROJECT).gch
+DEFINES := $(CONFIG) -D TIXML_USE_STL -D _CONSOLE -D FFI_BUILDING
+LFLAGS :=
+LIBS = $(SDK_LIBS) -framework Security
+OBJCOMP := ../bin/$(ARCH_DIR)/Release/gtests.a ../bin/$(ARCH_DIR)/invariant_core.a ../bin/$(ARCH_DIR)/$(CFG_DIR)/core.a /usr/local/opt/libffi/lib/libffi.a
+DYLIBS := ../bin/libVMProtectSDK.dylib
+INCFLAGS := -I ../third-party/gmock/include/ -I ../third-party/gtest/include/ -I ../third-party/gmock/ -I ../third-party/gtest/
+
+include ../mac_common.mak
+include ../gnu_simple.mak
diff --git a/unit-tests/mac_unit-tests32.mak b/unit-tests/mac_unit-tests32.mak
new file mode 100644
index 0000000..0d1528e
--- /dev/null
+++ b/unit-tests/mac_unit-tests32.mak
@@ -0,0 +1,3 @@
+ARCH := i386
+ARCH_DIR := 32
+include mac_unit-tests.mak
diff --git a/unit-tests/mac_unit-tests64.mak b/unit-tests/mac_unit-tests64.mak
new file mode 100644
index 0000000..1015f81
--- /dev/null
+++ b/unit-tests/mac_unit-tests64.mak
@@ -0,0 +1,3 @@
+ARCH := x86_64
+ARCH_DIR := 64
+include mac_unit-tests.mak
diff --git a/unit-tests/macfile_tests.cc b/unit-tests/macfile_tests.cc
new file mode 100644
index 0000000..f812add
--- /dev/null
+++ b/unit-tests/macfile_tests.cc
@@ -0,0 +1,462 @@
+#include "../runtime/common.h"
+#include "../runtime/crypto.h"
+#include "../core/objects.h"
+#include "../core/osutils.h"
+#include "../core/streams.h"
+#include "../core/core.h"
+#include "../core/files.h"
+#include "../core/processors.h"
+#include "../core/macfile.h"
+#include "../core/mac_runtime32.dylib.inc"
+#include "../core/mac_runtime64.dylib.inc"
+
+TEST(MacFileTest, TestOpen1)
+{
+ MacFile mf(NULL);
+
+ ASSERT_EQ(mf.Open("test-binaries/ios-app-test2-arm", true), osUnsupportedCPU);
+}
+
+TEST(MacFileTest, TestOpen2)
+{
+ // Test: read header of iOS/i386 file. Read should finish successfully.
+ MacFile mf(NULL);
+ ISectionList *segl;
+ MacSectionList *secl;
+ MacSymbolList *syml;
+ IImportList *impl;
+
+ ASSERT_EQ(mf.Open("test-binaries/ios-app-test1-i386", true), osSuccess);
+ // Check architectures.
+ EXPECT_EQ(mf.count(), 1ul);
+ MacArchitecture &arch = *mf.item(0);
+ EXPECT_EQ(arch.name().compare("i386"), 0);
+ EXPECT_EQ(arch.owner()->format_name().compare("Mach-O"), 0);
+ EXPECT_EQ(arch.entry_point(), 0x2130ull);
+ // Check segments were read.
+ segl = arch.segment_list();
+ ASSERT_EQ(segl->count(), 4ul);
+ EXPECT_EQ(segl->item(0)->name().compare("__PAGEZERO"), 0);
+ EXPECT_EQ(segl->item(0)->memory_type(), mtNone);
+ EXPECT_EQ(segl->item(1)->name().compare("__TEXT"), 0);
+ EXPECT_EQ((int)segl->item(1)->memory_type(), (mtReadable | mtExecutable));
+ EXPECT_EQ(segl->item(2)->name().compare("__DATA"), 0);
+ EXPECT_EQ((int)segl->item(2)->memory_type(), (mtReadable | mtWritable));
+ EXPECT_EQ(segl->item(3)->name().compare("__LINKEDIT"), 0);
+ EXPECT_EQ(segl->item(3)->memory_type(), mtReadable);
+ // Check sections were read.
+ secl = arch.section_list();
+ ASSERT_EQ(secl->count(), 18ul);
+ EXPECT_EQ(secl->item(0)->name().compare("__text"), 0);
+ EXPECT_EQ(secl->item(1)->name().compare("__symbol_stub"), 0);
+ EXPECT_EQ(secl->item(2)->name().compare("__stub_helper"), 0);
+ EXPECT_EQ(secl->item(3)->name().compare("__cstring"), 0);
+ EXPECT_EQ(secl->item(4)->name().compare("__unwind_info"), 0);
+ EXPECT_EQ(secl->item(5)->name().compare("__eh_frame"), 0);
+ EXPECT_EQ(secl->item(6)->name().compare("__program_vars"), 0);
+ EXPECT_EQ(secl->item(7)->name().compare("__nl_symbol_ptr"), 0);
+ EXPECT_EQ(secl->item(8)->name().compare("__la_symbol_ptr"), 0);
+ EXPECT_EQ(secl->item(9)->name().compare("__objc_classlist"), 0);
+ EXPECT_EQ(secl->item(10)->name().compare("__objc_protolist"), 0);
+ EXPECT_EQ(secl->item(11)->name().compare("__objc_imageinfo"), 0);
+ EXPECT_EQ(secl->item(12)->name().compare("__objc_const"), 0);
+ EXPECT_EQ(secl->item(13)->name().compare("__objc_selrefs"), 0);
+ EXPECT_EQ(secl->item(14)->name().compare("__objc_classrefs"), 0);
+ EXPECT_EQ(secl->item(15)->name().compare("__objc_superrefs"), 0);
+ EXPECT_EQ(secl->item(16)->name().compare("__objc_data"), 0);
+ EXPECT_EQ(secl->item(17)->name().compare("__data"), 0);
+ // Check symbols.
+ syml = arch.symbol_list();
+ ASSERT_EQ(syml->count(), 129ul);
+ EXPECT_EQ(syml->item(0)->name()
+ .compare("/Users/macuser/work2/ios-test2/ios-test2/"), 0);
+ // Check imports.
+ impl = arch.import_list();
+ ASSERT_EQ(impl->count(), 6ul);
+ EXPECT_EQ(impl->item(0)->name().compare("/System/Library/Frameworks/UIKit.framework/UIKit"), 0);
+ EXPECT_EQ(impl->item(5)->name().compare("/usr/lib/libobjc.A.dylib"), 0);
+ EXPECT_EQ(impl->item(5)->count(), 11ul);
+ EXPECT_EQ(impl->item(5)->item(0)->name().compare("__objc_empty_cache"), 0);
+ EXPECT_EQ(impl->item(5)->item(1)->name().compare("__objc_empty_cache"), 0);
+ EXPECT_EQ(impl->item(5)->item(2)->name().compare("__objc_empty_cache"), 0);
+ EXPECT_EQ(impl->item(5)->item(3)->name().compare("__objc_empty_cache"), 0);
+ EXPECT_EQ(impl->item(5)->item(4)->name().compare("__objc_empty_vtable"), 0);
+ EXPECT_EQ(impl->item(5)->item(5)->name().compare("__objc_empty_vtable"), 0);
+ EXPECT_EQ(impl->item(5)->item(6)->name().compare("__objc_empty_vtable"), 0);
+ EXPECT_EQ(impl->item(5)->item(7)->name().compare("__objc_empty_vtable"), 0);
+ EXPECT_EQ(impl->item(5)->item(8)->name().compare("_objc_msgSend"), 0);
+ EXPECT_EQ(impl->item(5)->item(9)->name().compare("_objc_msgSendSuper2"), 0);
+ EXPECT_EQ(impl->item(5)->item(10)->name().compare("_objc_setProperty"), 0);
+ mf.Close();
+ EXPECT_EQ(mf.count(), 0ul);
+}
+
+TEST(MacFileTest, TestOpen3)
+{
+ // Test: read header of iOS/x86-64 file. Read should finish successfully.
+ MacFile mf(NULL);
+ ISectionList *segl;
+ MacSectionList *secl;
+ MacSymbolList *syml;
+ IImportList *impl;
+ IExportList *expl;
+
+ ASSERT_EQ(mf.Open("test-binaries/macos-app-test1-amd64", true), osSuccess);
+ // Check architectures.
+ ASSERT_EQ(mf.count(), 1ul);
+ MacArchitecture &arch = *mf.item(0);
+ EXPECT_EQ(arch.name().compare("x86_64"), 0);
+ EXPECT_EQ(arch.owner()->format_name().compare("Mach-O"), 0);
+ EXPECT_EQ(arch.entry_point(), 0x0000000100000c04ULL);
+ // Check segments were read.
+ segl = arch.segment_list();
+ ASSERT_EQ(segl->count(), 4ul);
+ EXPECT_EQ(segl->item(0)->name().compare("__PAGEZERO"), 0);
+ EXPECT_EQ(segl->item(0)->memory_type(), mtNone);
+ EXPECT_EQ(segl->item(1)->name().compare("__TEXT"), 0);
+ EXPECT_EQ((int)segl->item(1)->memory_type(), (mtReadable | mtExecutable));
+ EXPECT_EQ(segl->item(2)->name().compare("__DATA"), 0);
+ EXPECT_EQ((int)segl->item(2)->memory_type(), (mtReadable | mtWritable));
+ EXPECT_EQ(segl->item(3)->name().compare("__LINKEDIT"), 0);
+ EXPECT_EQ(segl->item(3)->memory_type(), mtReadable);
+ // Check sections were read.
+ secl = arch.section_list();
+ ASSERT_EQ(secl->count(), 10ul);
+ EXPECT_EQ(secl->item(0)->name().compare("__text"), 0);
+ EXPECT_EQ(secl->item(1)->name().compare("__stubs"), 0);
+ EXPECT_EQ(secl->item(2)->name().compare("__stub_helper"), 0);
+ EXPECT_EQ(secl->item(3)->name().compare("__cstring"), 0);
+ EXPECT_EQ(secl->item(4)->name().compare("__unwind_info"), 0);
+ EXPECT_EQ(secl->item(5)->name().compare("__eh_frame"), 0);
+ EXPECT_EQ(secl->item(6)->name().compare("__dyld"), 0);
+ EXPECT_EQ(secl->item(7)->name().compare("__got"), 0);
+ EXPECT_EQ(secl->item(8)->name().compare("__la_symbol_ptr"), 0);
+ EXPECT_EQ(secl->item(9)->name().compare("__data"), 0);
+ // Check symbols.
+ syml = arch.symbol_list();
+ ASSERT_EQ(syml->count(), 57ul);
+ EXPECT_EQ(syml->item(2)->name()
+ .compare("/Users/mac/Library/Developer/Xcode/DerivedData/hello-flxnqzrlabvwqrdcesuuqdaabhfa/Build/Intermediates/hello.build/Release/hello.build/Objects-normal/x86_64/main.o"), 0);
+ // Check imports.
+ impl = arch.import_list();
+ ASSERT_EQ(impl->count(), 3ul);
+ EXPECT_EQ(impl->item(0)->name().compare("/usr/lib/libstdc++.6.dylib"), 0);
+ EXPECT_EQ(impl->item(1)->name().compare("/usr/lib/libgcc_s.1.dylib"), 0);
+ EXPECT_EQ(impl->item(2)->name().compare("/usr/lib/libSystem.B.dylib"), 0);
+ // Check exports.
+ expl = arch.export_list();
+ ASSERT_EQ(expl->count(), 5ul);
+ EXPECT_EQ(expl->item(0)->name().compare("_NXArgc"), 0);
+ EXPECT_EQ(expl->item(1)->name().compare("_NXArgv"), 0);
+ EXPECT_EQ(expl->item(2)->name().compare("___progname"), 0);
+ EXPECT_EQ(expl->item(3)->name().compare("_environ"), 0);
+ EXPECT_EQ(expl->item(4)->name().compare("start"), 0);
+ EXPECT_EQ(expl->item(4)->address(), 0x100000c04ULL);
+ mf.Close();
+ EXPECT_EQ(mf.count(), 0ul);
+}
+
+TEST(MacFileTest, OpenMacDLL)
+{
+ MacFile mf(NULL);
+
+ EXPECT_EQ(mf.Open("test-binaries/macos-dll-test1-i386", foRead), osSuccess);
+ // Check architectures.
+ ASSERT_EQ(mf.count(), 1ul);
+ MacArchitecture &arch = *mf.item(0);
+ // Check exports.
+ IExportList *exp = arch.export_list();
+ EXPECT_EQ(exp->name().compare("@executable_path/hello_lib_cpp.dylib"), 0);
+ ASSERT_EQ(exp->count(), 1ul);
+ EXPECT_EQ(exp->item(0)->name().compare("__ZN13hello_lib_cpp10HelloWorldEPKc"), 0);
+ EXPECT_EQ(exp->item(0)->forwarded_name().compare(""), 0);
+ EXPECT_EQ(exp->item(0)->address(), 0x00000deaull);
+ // Check fixups.
+ IFixupList *fixup_list = arch.fixup_list();
+ ASSERT_EQ(fixup_list->count(), 23ul);
+ EXPECT_EQ(fixup_list->item(0)->address(), 0x00000e84ull);
+ EXPECT_EQ(fixup_list->item(0)->type(), ftHighLow);
+ EXPECT_EQ(fixup_list->item(22)->address(), 0x00001034ull);
+ EXPECT_EQ(fixup_list->item(22)->type(), ftHighLow);
+ mf.Close();
+ EXPECT_EQ(mf.count(), 0ul);
+}
+
+TEST(MacFileTest, Clone)
+{
+ MacFile mf(NULL);
+
+ ASSERT_EQ(mf.Open("test-binaries/ios-app-test1-i386", foRead), osSuccess);
+ MacFile *f = mf.Clone(mf.file_name().c_str());
+ ASSERT_EQ(mf.count(), f->count());
+ MacArchitecture &src = *mf.item(0);
+ MacArchitecture &dst = *f->item(0);
+ EXPECT_EQ(src.owner()->format_name().compare(dst.owner()->format_name()), 0);
+ EXPECT_EQ(src.name().compare(dst.name()), 0);
+ EXPECT_EQ(src.cpu_address_size(), dst.cpu_address_size());
+ EXPECT_EQ(src.entry_point(), dst.entry_point());
+ EXPECT_EQ(src.command_list()->count(), dst.command_list()->count());
+ EXPECT_EQ(src.command_list()->count(), dst.command_list()->count());
+ EXPECT_EQ(src.segment_list()->count(), dst.segment_list()->count());
+ EXPECT_EQ(src.section_list()->count(), dst.section_list()->count());
+ EXPECT_EQ(src.symbol_list()->count(), dst.symbol_list()->count());
+ EXPECT_EQ(src.import_list()->count(), dst.import_list()->count());
+ EXPECT_EQ(src.fixup_list()->count(), dst.fixup_list()->count());
+ EXPECT_EQ(src.export_list()->count(), dst.export_list()->count());
+ std::string symbol_name = src.indirect_symbol_list()->item(1)->symbol()->name();
+ std::string segment_name = src.section_list()->item(0)->parent()->name();
+ mf.Close();
+ EXPECT_EQ(dst.indirect_symbol_list()->item(1)->symbol()->name().compare(symbol_name), 0);
+ EXPECT_EQ(dst.section_list()->item(0)->parent()->name().compare(segment_name), 0);
+ delete f;
+}
+
+TEST(MacFileTest, Runtime_x32)
+{
+ MacFile file(NULL);
+
+ ASSERT_TRUE(file.OpenResource(mac_runtime32_dylib_file, sizeof(mac_runtime32_dylib_file), true));
+ ASSERT_EQ(file.count(), 1ul);
+ MacArchitecture *arch = file.item(0);
+ Buffer buffer(&mac_runtime32_dylib_code[0]);
+ arch->ReadFromBuffer(buffer);
+ EXPECT_EQ(arch->export_list()->count(), 21ul);
+ EXPECT_GT(arch->function_list()->count(), 0ul);
+}
+
+TEST(MacFileTest, Runtime_x64)
+{
+ MacFile file(NULL);
+
+ ASSERT_TRUE(file.OpenResource(mac_runtime64_dylib_file, sizeof(mac_runtime64_dylib_file), true));
+ ASSERT_EQ(file.count(), 1ul);
+ MacArchitecture *arch = file.item(0);
+ Buffer buffer(&mac_runtime64_dylib_code[0]);
+ arch->ReadFromBuffer(buffer);
+ EXPECT_EQ(arch->export_list()->count(), 21ul);
+ EXPECT_GT(arch->function_list()->count(), 0ul);
+}
+
+TEST(MacFileTest, Compile_x32)
+{
+ MacFile mf(NULL);
+ size_t i;
+ MacSegment *segment;
+
+ ASSERT_EQ(mf.Open("test-binaries/exc-osx-x86", foRead), osSuccess);
+ MacArchitecture *arch = mf.item(0);
+ std::string file_name = mf.file_name() + "_vmp";
+ MacFile *f = mf.Clone(file_name.c_str());
+ CompileOptions options;
+ options.flags = cpMaximumProtection;
+ options.section_name = ".vmp";
+ ASSERT_TRUE(f->Compile(options));
+ MacArchitecture *dst = f->item(0);
+ MacSegment *text_segment = dst->segment_list()->GetSectionByName(SEG_TEXT);
+ ASSERT_TRUE(text_segment != NULL);
+ if (dst->entry_point()) {
+ segment = dst->segment_list()->GetSectionByAddress(dst->entry_point());
+ ASSERT_EQ(segment, text_segment);
+ }
+ size_t pointer_size = dst->cpu_address_size() == osDWord ? 4 : 8;
+ for (i = 0; i < dst->section_list()->count(); i++) {
+ MacSection *section = dst->section_list()->item(i);
+ if (section->type() == S_MOD_INIT_FUNC_POINTERS) {
+ ASSERT_TRUE((section->address() % pointer_size) == 0);
+ ASSERT_TRUE((section->size() % pointer_size) == 0);
+ ASSERT_TRUE(dst->AddressSeek(section->address()));
+ for (uint64_t j = 0; j < section->size(); j += pointer_size) {
+ uint64_t address = 0;
+ dst->Read(&address, pointer_size);
+ segment = dst->segment_list()->GetSectionByAddress(address);
+ ASSERT_EQ(segment, text_segment);
+ }
+ }
+ }
+ for (i = 0; i < dst->fixup_list()->count(); i++) {
+ MacFixup *fixup = dst->fixup_list()->item(i);
+ if (fixup->is_relocation())
+ continue;
+ MacSegment *segment = dst->segment_list()->GetSectionByAddress(fixup->address());
+ ASSERT_TRUE(segment != NULL);
+ switch (fixup->bind_type()) {
+ case REBASE_TYPE_POINTER:
+ ASSERT_EQ(segment->memory_type() & (mtExecutable | mtWritable), mtWritable);
+ break;
+ case REBASE_TYPE_TEXT_ABSOLUTE32:
+ case REBASE_TYPE_TEXT_PCREL32:
+ ASSERT_EQ(segment->memory_type() & (mtExecutable | mtWritable), mtExecutable);
+ break;
+ }
+ }
+ // check AV buffer
+ ASSERT_EQ(dst->segment_list()->count(), 7ul);
+ ASSERT_TRUE(dst->AddressSeek(dst->segment_list()->item(4)->address()));
+ uint32_t sum = 0;
+ for (i = 0; i < 64; i++) {
+ sum += dst->ReadDWord();
+ }
+ EXPECT_EQ(sum, 0xB7896EB5);
+ // delete file from disk
+ delete f;
+ remove(file_name.c_str());
+}
+
+TEST(MacFileTest, Compile_x64)
+{
+ MacFile mf(NULL);
+ size_t i;
+ MacSegment *segment;
+
+ ASSERT_EQ(mf.Open("test-binaries/exc-osx-x64", foRead), osSuccess);
+ MacArchitecture *arch = mf.item(0);
+ std::string file_name = mf.file_name() + "_vmp";
+ MacFile *f = mf.Clone(file_name.c_str());
+ CompileOptions options;
+ options.flags = cpMaximumProtection;
+ options.section_name = ".vmp";
+ ASSERT_TRUE(f->Compile(options));
+ MacArchitecture *dst = f->item(0);
+ MacSegment *text_segment = dst->segment_list()->GetSectionByName(SEG_TEXT);
+ ASSERT_TRUE(text_segment != NULL);
+ if (dst->entry_point()) {
+ segment = dst->segment_list()->GetSectionByAddress(dst->entry_point());
+ ASSERT_EQ(segment, text_segment);
+ }
+ size_t pointer_size = dst->cpu_address_size() == osDWord ? 4 : 8;
+ for (i = 0; i < dst->section_list()->count(); i++) {
+ MacSection *section = dst->section_list()->item(i);
+ if (section->type() == S_MOD_INIT_FUNC_POINTERS) {
+ ASSERT_TRUE((section->address() % pointer_size) == 0);
+ ASSERT_TRUE((section->size() % pointer_size) == 0);
+ ASSERT_TRUE(dst->AddressSeek(section->address()));
+ for (uint64_t j = 0; j < section->size(); j += pointer_size) {
+ uint64_t address = 0;
+ dst->Read(&address, pointer_size);
+ segment = dst->segment_list()->GetSectionByAddress(address);
+ ASSERT_EQ(segment, text_segment);
+ }
+ }
+ }
+ for (i = 0; i < dst->fixup_list()->count(); i++) {
+ MacFixup *fixup = dst->fixup_list()->item(i);
+ if (fixup->is_relocation())
+ continue;
+ MacSegment *segment = dst->segment_list()->GetSectionByAddress(fixup->address());
+ ASSERT_TRUE(segment != NULL);
+ switch (fixup->bind_type()) {
+ case REBASE_TYPE_POINTER:
+ ASSERT_EQ(segment->memory_type() & (mtExecutable | mtWritable), mtWritable);
+ break;
+ case REBASE_TYPE_TEXT_ABSOLUTE32:
+ case REBASE_TYPE_TEXT_PCREL32:
+ ASSERT_EQ(segment->memory_type() & (mtExecutable | mtWritable), mtExecutable);
+ break;
+ }
+ }
+ // check AV buffer
+ ASSERT_EQ(dst->segment_list()->count(), 7ul);
+ ASSERT_TRUE(dst->AddressSeek(dst->segment_list()->item(4)->address()));
+ uint32_t sum = 0;
+ for (i = 0; i < 64; i++) {
+ sum += dst->ReadDWord();
+ }
+ EXPECT_EQ(sum, 0xB7896EB5);
+ // delete file from disk
+ delete f;
+ remove(file_name.c_str());
+}
+
+#ifdef __APPLE__
+#ifndef DEMO
+static bool execFile(const std::string &fileName, DWORD &exitCode)
+{
+ exitCode = 0xFFFFFFF;
+ int ret = system(fileName.c_str());
+ if (ret != -1)
+ {
+ exitCode = DWORD(ret);
+ return true;
+ }
+ return false;
+}
+
+/*
+// exc.cpp:
+// clang++ -std=c++11 -arch x86_64 -o exc-osx-x64 exc.cpp ../bin/libVMProtectSDK.dylib -I ../sdk
+// clang++ -std=c++11 -arch i386 -o exc-osx-x86 exc.cpp ../bin/libVMProtectSDK.dylib -I ../sdk
+#include <stdio.h>
+#include "VMProtectSDK.h"
+
+__declspec(noinline) void try1()
+{
+ printf("try 1\n");
+ try {
+ throw 1;
+ }
+ catch (int) {
+ printf("catch 1\n");
+ throw;
+ }
+ printf("end 1\n\n");
+}
+
+int main()
+{
+ if (VMProtectIsDebuggerPresent(true))
+ printf("debugger detected\n");
+ if (VMProtectIsVirtualMachinePresent())
+ printf("virtual machine detected\n");
+
+ printf("try main\n");
+ try {
+ try1();
+ }
+ catch (...) {
+ printf("catch main\n");
+ }
+ printf("end main\n");
+
+ return 0;
+}
+*/
+
+TEST(MacFileTest, EXC_x32)
+{
+ MacFile pf(NULL);
+ ASSERT_EQ(pf.Open("test-binaries/exc-osx-x86", foRead), osSuccess);
+ MacArchitecture *arch = pf.item(0);
+ arch->function_list()->AddByAddress(0x01C60, ctVirtualization, 0, true, NULL); // main
+ arch->function_list()->AddByAddress(0x01BA0, ctUltra, 0, true, NULL); // try1
+ std::string file_name = pf.file_name() + "_vmp";
+ MacFile *f = pf.Clone(file_name.c_str());
+ CompileOptions options;
+ options.flags = cpMaximumProtection;
+ options.section_name = ".vmp";
+ ASSERT_TRUE(f->Compile(options));
+ delete f;
+ DWORD ret;
+ ASSERT_TRUE(execFile(file_name, ret));
+ ASSERT_EQ(ret, 0u);
+}
+
+TEST(MacFileTest, EXC_x64)
+{
+ MacFile pf(NULL);
+ ASSERT_EQ(pf.Open("test-binaries/exc-osx-x64", foRead), osSuccess);
+ MacArchitecture *arch = pf.item(0);
+ arch->function_list()->AddByAddress(0x0000000100000C50, ctVirtualization, 0, true, NULL); // main
+ arch->function_list()->AddByAddress(0x0000000100000BB0, ctUltra, 0, true, NULL); // try1
+ std::string file_name = pf.file_name() + "_vmp";
+ MacFile *f = pf.Clone(file_name.c_str());
+ CompileOptions options;
+ options.flags = cpMaximumProtection;
+ options.section_name = ".vmp";
+ ASSERT_TRUE(f->Compile(options));
+ delete f;
+ DWORD ret;
+ ASSERT_TRUE(execFile(file_name, ret));
+ ASSERT_EQ(ret, 0u);
+}
+#endif
+#endif \ No newline at end of file
diff --git a/unit-tests/pefile_tests.cc b/unit-tests/pefile_tests.cc
new file mode 100644
index 0000000..f6d14f0
--- /dev/null
+++ b/unit-tests/pefile_tests.cc
@@ -0,0 +1,553 @@
+#include "../runtime/common.h"
+#include "../runtime/crypto.h"
+#include "../core/objects.h"
+#include "../core/osutils.h"
+#include "../core/streams.h"
+#include "../core/core.h"
+#include "../core/files.h"
+#include "../core/processors.h"
+#include "../core/pefile.h"
+#include "../core/packer.h"
+#include "../third-party/lzma/LzmaDecode.h"
+
+#ifdef DEMO
+ #include "../core/win_runtime32demo.dll.inc"
+ #include "../core/win_runtime64demo.dll.inc"
+#else
+ #include "../core/win_runtime32.dll.inc"
+ #include "../core/win_runtime64.dll.inc"
+#endif
+
+#ifdef VMP_GNU
+ #include <stdlib.h>
+#endif
+
+TEST(PEFileTest, OpenEXE)
+{
+ // Test: read header of Win32/Intel file. Read should finish successfully.
+ PEFile pf(NULL);
+
+ ASSERT_EQ(pf.Open("test-binaries/win32-app-test1-i386", foRead), osSuccess);
+ // Check architectures.
+ ASSERT_EQ(pf.count(), 1ul);
+ PEArchitecture *arch = pf.arch_pe();
+ EXPECT_EQ(arch->name().compare("i386"), 0);
+ EXPECT_EQ(arch->owner()->format_name().compare("PE"), 0);
+ EXPECT_EQ(arch->cpu_address_size(), osDWord);
+ EXPECT_EQ(arch->image_base(), 0x400000ull);
+ EXPECT_EQ(arch->entry_point(), 0x401000ull);
+ // Check segments.
+ ISectionList *segment_list = arch->segment_list();
+ ASSERT_EQ(segment_list->count(), 3ul);
+ EXPECT_EQ(segment_list->item(0)->name().compare(".text"), 0);
+ EXPECT_EQ(segment_list->item(1)->name().compare(".rdata"), 0);
+ EXPECT_EQ(segment_list->item(2)->name().compare(".data"), 0);
+ EXPECT_EQ((int)segment_list->item(0)->memory_type(), (mtReadable | mtExecutable));
+ EXPECT_EQ((int)segment_list->item(1)->memory_type(), mtReadable);
+ EXPECT_EQ((int)segment_list->item(2)->memory_type(), (mtReadable | mtWritable));
+ // Check imports.
+ IImportList *imp = arch->import_list();
+ ASSERT_EQ(imp->count(), 3ul);
+ EXPECT_EQ(imp->item(0)->name().compare("user32.dll"), 0);
+ ASSERT_EQ(imp->item(0)->count(), 6ul);
+ EXPECT_EQ(imp->item(0)->item(0)->name().compare("SetFocus"), 0);
+ EXPECT_EQ(imp->item(0)->item(0)->address(), 0x402028ull);
+ EXPECT_EQ(imp->item(0)->item(1)->name().compare("MessageBoxA"), 0);
+ EXPECT_EQ(imp->item(0)->item(1)->address(), 0x40202cull);
+ EXPECT_EQ(imp->item(0)->item(2)->name().compare("GetDlgItemTextA"), 0);
+ EXPECT_EQ(imp->item(0)->item(2)->address(), 0x402030ull);
+ EXPECT_EQ(imp->item(0)->item(3)->name().compare("GetDlgItem"), 0);
+ EXPECT_EQ(imp->item(0)->item(3)->address(), 0x402034ull);
+ EXPECT_EQ(imp->item(0)->item(4)->name().compare("EndDialog"), 0);
+ EXPECT_EQ(imp->item(0)->item(4)->address(), 0x402038ull);
+ EXPECT_EQ(imp->item(0)->item(5)->name().compare("DialogBoxIndirectParamA"), 0);
+ EXPECT_EQ(imp->item(0)->item(5)->address(), 0x40203cull);
+ EXPECT_EQ(imp->item(1)->name().compare("kernel32.dll"), 0);
+ ASSERT_EQ(imp->item(1)->count(), 5ul);
+ EXPECT_EQ(imp->item(1)->item(0)->name().compare("MultiByteToWideChar"), 0);
+ EXPECT_EQ(imp->item(1)->item(0)->address(), 0x402010ull);
+ EXPECT_EQ(imp->item(1)->item(1)->name().compare("GlobalFree"), 0);
+ EXPECT_EQ(imp->item(1)->item(1)->address(), 0x402014ull);
+ EXPECT_EQ(imp->item(1)->item(2)->name().compare("ExitProcess"), 0);
+ EXPECT_EQ(imp->item(1)->item(2)->address(), 0x402018ull);
+ EXPECT_EQ(imp->item(1)->item(3)->name().compare("GetModuleHandleA"), 0);
+ EXPECT_EQ(imp->item(1)->item(3)->address(), 0x40201cull);
+ EXPECT_EQ(imp->item(1)->item(4)->name().compare("GlobalAlloc"), 0);
+ EXPECT_EQ(imp->item(1)->item(4)->address(), 0x402020ull);
+ EXPECT_EQ(imp->item(2)->name().compare("VMProtectSDK32.dll"), 0);
+ ASSERT_EQ(imp->item(2)->count(), 3ul);
+ EXPECT_EQ(imp->item(2)->item(0)->name().compare("VMProtectDecryptStringA"), 0);
+ EXPECT_EQ(imp->item(2)->item(0)->address(), 0x402000ull);
+ EXPECT_EQ(imp->item(2)->item(1)->name().compare("VMProtectEnd"), 0);
+ EXPECT_EQ(imp->item(2)->item(1)->address(), 0x402004ull);
+ EXPECT_EQ(imp->item(2)->item(2)->name().compare("VMProtectBegin"), 0);
+ EXPECT_EQ(imp->item(2)->item(2)->address(), 0x402008ull);
+ // Check fixups.
+ IFixupList *fixup_list = arch->fixup_list();
+ EXPECT_EQ(fixup_list->count(), 0ul);
+ // Check resources.
+ IResourceList *resource_list = arch->resource_list();
+ EXPECT_EQ(resource_list->count(), 0ul);
+ // Check lists were cleared.
+ pf.Close();
+ EXPECT_EQ(pf.count(), 0ul);
+}
+
+TEST(PEFileTest, OpenDLL)
+{
+ PEFile pf(NULL);
+
+ ASSERT_EQ(pf.Open("test-binaries/win32-dll-test1-i386", foRead), osSuccess);
+ // Check architectures.
+ ASSERT_EQ(pf.count(), 1ul);
+ PEArchitecture *arch = pf.arch_pe();
+ // Check exports.
+ IExportList *exp = arch->export_list();
+ EXPECT_EQ(exp->name().compare("ShimEng.dll"), 0);
+ ASSERT_EQ(exp->count(), 11ul);
+ EXPECT_EQ(exp->item(0)->name().compare("SE_DllLoaded"), 0);
+ EXPECT_EQ(exp->item(0)->forwarded_name().compare("APPHELP.SE_DllLoaded"), 0);
+ EXPECT_EQ(exp->item(0)->address(), 0x3ff31257ull);
+ EXPECT_EQ(exp->item(10)->name().compare("SE_ProcessDying"), 0);
+ EXPECT_EQ(exp->item(10)->forwarded_name().compare("APPHELP.SE_ProcessDying"), 0);
+ EXPECT_EQ(exp->item(10)->address(), 0x3ff31358ull);
+ // Check fixups.
+ IFixupList *fixup_list = arch->fixup_list();
+ ASSERT_EQ(fixup_list->count(), 12ul);
+ EXPECT_EQ(fixup_list->item(0)->address(), 0x3ff3103aull);
+ EXPECT_EQ(fixup_list->item(0)->type(), ftHighLow);
+ EXPECT_EQ(fixup_list->item(1)->address(), 0x3ff31042ull);
+ EXPECT_EQ(fixup_list->item(1)->type(), ftHighLow);
+ EXPECT_EQ(fixup_list->item(2)->address(), 0x3ff3104dull);
+ EXPECT_EQ(fixup_list->item(2)->type(), ftHighLow);
+ EXPECT_EQ(fixup_list->item(3)->address(), 0x3ff31089ull);
+ EXPECT_EQ(fixup_list->item(3)->type(), ftHighLow);
+ EXPECT_EQ(fixup_list->item(4)->address(), 0x3ff310a2ull);
+ EXPECT_EQ(fixup_list->item(4)->type(), ftHighLow);
+ EXPECT_EQ(fixup_list->item(5)->address(), 0x3FF310AEull);
+ EXPECT_EQ(fixup_list->item(5)->type(), ftHighLow);
+ EXPECT_EQ(fixup_list->item(6)->address(), 0x3FF310B6ull);
+ EXPECT_EQ(fixup_list->item(6)->type(), ftHighLow);
+ EXPECT_EQ(fixup_list->item(7)->address(), 0x3FF310BEull);
+ EXPECT_EQ(fixup_list->item(7)->type(), ftHighLow);
+ EXPECT_EQ(fixup_list->item(8)->address(), 0x3FF310CAull);
+ EXPECT_EQ(fixup_list->item(8)->type(), ftHighLow);
+ EXPECT_EQ(fixup_list->item(9)->address(), 0x3FF310E0ull);
+ EXPECT_EQ(fixup_list->item(9)->type(), ftHighLow);
+ EXPECT_EQ(fixup_list->item(10)->address(), 0x3FF310E8ull);
+ EXPECT_EQ(fixup_list->item(10)->type(), ftHighLow);
+ EXPECT_EQ(fixup_list->item(11)->address(), 0x3ff310f0ull);
+ EXPECT_EQ(fixup_list->item(11)->type(), ftHighLow);
+ // Check resources.
+ IResourceList *resource_list = arch->resource_list();
+ ASSERT_EQ(resource_list->count(), 1ul);
+ EXPECT_EQ(resource_list->item(0)->type(), rtVersionInfo);
+ ASSERT_EQ(resource_list->item(0)->count(), 1ul);
+ EXPECT_EQ(resource_list->item(0)->item(0)->name(), "1");
+ EXPECT_EQ(resource_list->item(0)->item(0)->count(), 1ul);
+ EXPECT_EQ(resource_list->item(0)->item(0)->item(0)->name(), "1033");
+ EXPECT_EQ(resource_list->item(0)->item(0)->item(0)->address(), 0x3ff33060ull);
+ EXPECT_EQ(resource_list->item(0)->item(0)->item(0)->size(), 0x3acul);
+ // Check lists were cleared.
+ pf.Close();
+ EXPECT_EQ(pf.count(), 0ul);
+}
+
+TEST(PEFileTest, Clone)
+{
+ PEFile pf(NULL);
+
+ ASSERT_EQ(pf.Open("test-binaries/win32-app-test1-i386", foRead), osSuccess);
+ PEFile *f = pf.Clone(pf.file_name().c_str());
+ EXPECT_EQ(pf.count(), f->count());
+ PEArchitecture &src = *pf.arch_pe();
+ PEArchitecture &dst = *f->arch_pe();
+ EXPECT_EQ(src.owner()->format_name().compare(dst.owner()->format_name()), 0);
+ EXPECT_EQ(src.name().compare(dst.name()), 0);
+ EXPECT_EQ(src.cpu_address_size(), dst.cpu_address_size());
+ EXPECT_EQ(src.entry_point(), dst.entry_point());
+ EXPECT_EQ(src.command_list()->count(), dst.command_list()->count());
+ EXPECT_EQ(src.segment_list()->count(), dst.segment_list()->count());
+ EXPECT_EQ(src.import_list()->count(), dst.import_list()->count());
+ EXPECT_EQ(src.fixup_list()->count(), dst.fixup_list()->count());
+ EXPECT_EQ(src.export_list()->count(), dst.export_list()->count());
+ EXPECT_EQ(src.resource_list()->count(), dst.resource_list()->count());
+ delete f;
+}
+
+TEST(PEFileTest, Runtime_x32)
+{
+ PEFile file(NULL);
+
+ ASSERT_TRUE(file.OpenResource(win_runtime32_dll_file, sizeof(win_runtime32_dll_file), true));
+ ASSERT_EQ(file.count(), 1ul);
+ PEArchitecture *arch = file.arch_pe();
+ Buffer buffer(&win_runtime32_dll_code[0]);
+ arch->ReadFromBuffer(buffer);
+ EXPECT_GT(arch->export_list()->count(), 0ul);
+ EXPECT_GT(arch->function_list()->count(), 0ul);
+}
+
+TEST(PEFileTest, Runtime_x64)
+{
+ PEFile file(NULL);
+
+ ASSERT_TRUE(file.OpenResource(win_runtime64_dll_file, sizeof(win_runtime64_dll_file), true));
+ ASSERT_EQ(file.count(), 1ul);
+ PEArchitecture *arch = file.arch_pe();
+ Buffer buffer(&win_runtime64_dll_code[0]);
+ arch->ReadFromBuffer(buffer);
+ EXPECT_GT(arch->export_list()->count(), 0ul);
+ EXPECT_GT(arch->function_list()->count(), 0ul);
+}
+
+TEST(PEFileTest, Compile_x32)
+{
+ PEFile pf(NULL);
+ size_t i;
+
+ ASSERT_EQ(pf.Open("test-binaries/win32-app-delphi-i386", foRead), osSuccess);
+ PEArchitecture *arch = pf.arch_pe();
+ for (i = 0; i < arch->map_function_list()->count(); i++) {
+ MapFunction *map_function = arch->map_function_list()->item(i);
+ if (map_function->type() == otString || map_function->type() == otAPIMarker || map_function->type() == otMarker)
+ arch->function_list()->AddByAddress(map_function->address(), ctVirtualization, 0, true, NULL);
+ }
+ ASSERT_EQ(arch->function_list()->count(), 4ul);
+ std::string file_name = pf.file_name()+".exe";
+ PEFile *f = pf.Clone(file_name.c_str());
+ CompileOptions options;
+ options.flags = cpMaximumProtection;
+ options.section_name = ".vmp";
+ ASSERT_TRUE(f->Compile(options));
+ delete f;
+ PEFile pf2(NULL);
+ ASSERT_EQ(pf2.Open(file_name.c_str(), foRead | foHeaderOnly), osSuccess);
+ ASSERT_EQ(pf2.count(), pf.count());
+ PEArchitecture &src = *pf.arch_pe();
+ PEArchitecture &dst = *pf2.arch_pe();
+ for (i = 0; i < src.fixup_list()->count(); i++) {
+ IFixup *src_fixup = src.fixup_list()->item(i);
+ IFixup *dst_fixup = src.fixup_list()->GetFixupByAddress(src_fixup->address());
+ EXPECT_EQ(src_fixup->address(), dst_fixup->address());
+ EXPECT_EQ(src_fixup->type(), dst_fixup->type());
+ EXPECT_EQ(src_fixup->size(), dst_fixup->size());
+ }
+ if (options.flags & cpResourceProtection) {
+ EXPECT_EQ(dst.resource_list()->count(), 4ul);
+ } else {
+ EXPECT_EQ(src.resource_list()->count(), dst.resource_list()->count());
+ for (i = 0; i < src.resource_list()->count(); i++) {
+ PEResource *src_resource = src.resource_list()->item(i);
+ PEResource *dst_resource = dst.resource_list()->item(i);
+ EXPECT_EQ(src_resource->count(), dst_resource->count());
+ EXPECT_EQ(src_resource->address(), dst_resource->address());
+ EXPECT_EQ(src_resource->size(), dst_resource->size());
+ EXPECT_EQ(src_resource->type(), dst_resource->type());
+ EXPECT_EQ(src_resource->name(), dst_resource->name());
+ }
+ }
+ // check AV buffer
+ ASSERT_EQ(dst.segment_list()->count(), 13ul);
+ ASSERT_TRUE(dst.AddressSeek(dst.segment_list()->item(10)->address()));
+ uint32_t sum = 0;
+ for (i = 0; i < 64; i++) {
+ sum += dst.ReadDWord();
+ }
+ EXPECT_EQ(sum, 0xB7896EB5);
+ // delete file from disk
+ pf2.Close();
+ remove(file_name.c_str());
+}
+
+TEST(PEFileTest, Compile_DLL)
+{
+ PEFile pf(NULL);
+
+ ASSERT_EQ(pf.Open("test-binaries/win32-dll-test1-i386", foRead), osSuccess);
+ std::string file_name = pf.file_name()+".dll";
+ PEFile *f = pf.Clone(file_name.c_str());
+ CompileOptions options;
+ options.flags = cpPack;
+ options.section_name = ".vmp";
+ ASSERT_TRUE(f->Compile(options));
+ delete f;
+ PEFile pf2(NULL);
+ ASSERT_EQ(pf2.Open(file_name.c_str(), foRead | foHeaderOnly), osSuccess);
+ ASSERT_EQ(pf2.count(), pf.count());
+ PEArchitecture &src = *pf.arch_pe();
+ PEArchitecture &dst = *pf2.arch_pe();
+ size_t i;
+ for (i = 0; i < src.fixup_list()->count(); i++) {
+ IFixup *src_fixup = src.fixup_list()->item(i);
+ IFixup *dst_fixup = src.fixup_list()->GetFixupByAddress(src_fixup->address());
+ EXPECT_EQ(src_fixup->address(), dst_fixup->address());
+ EXPECT_EQ(src_fixup->type(), dst_fixup->type());
+ EXPECT_EQ(src_fixup->size(), dst_fixup->size());
+ }
+ ASSERT_EQ(src.resource_list()->count(), dst.resource_list()->count());
+ for (i = 0; i < src.resource_list()->count(); i++) {
+ PEResource *src_resource = src.resource_list()->item(i);
+ PEResource *dst_resource = dst.resource_list()->item(i);
+ EXPECT_EQ(src_resource->count(), dst_resource->count());
+ EXPECT_EQ(src_resource->address(), dst_resource->address());
+ EXPECT_EQ(src_resource->size(), dst_resource->size());
+ EXPECT_EQ(src_resource->type(), dst_resource->type());
+ EXPECT_EQ(src_resource->name(), dst_resource->name());
+ }
+ ASSERT_EQ(src.export_list()->count(), dst.export_list()->count());
+ for (i = 0; i < src.export_list()->count(); i++) {
+ PEExport *src_export = src.export_list()->item(i);
+ PEExport *dst_export = dst.export_list()->item(i);
+ EXPECT_EQ(src_export->name(), dst_export->name());
+ EXPECT_EQ(src_export->ordinal(), dst_export->ordinal());
+ if (src_export->forwarded_name().empty()) {
+ EXPECT_EQ(src_export->address(), dst_export->address());
+ } else {
+ EXPECT_EQ(src_export->forwarded_name(), dst_export->forwarded_name());
+ }
+ }
+ // check AV buffer
+ ASSERT_EQ(dst.segment_list()->count(), 7ul);
+ ASSERT_TRUE(dst.AddressSeek(dst.segment_list()->item(4)->address()));
+ uint32_t sum = 0;
+ for (i = 0; i < 64; i++) {
+ sum += dst.ReadDWord();
+ }
+ EXPECT_EQ(sum, 0xB7896EB5);
+ // delete file from disk
+ pf2.Close();
+ remove(file_name.c_str());
+}
+
+TEST(PEFileTest, Compile_x64)
+{
+ PEFile pf(NULL);
+
+ ASSERT_EQ(pf.Open("test-binaries/win64-app-msvc-amd64", foRead), osSuccess);
+ PEArchitecture *arch = pf.arch_pe();
+ size_t i;
+ for (i = 0; i < arch->map_function_list()->count(); i++) {
+ MapFunction *map_function = arch->map_function_list()->item(i);
+ if (map_function->type() == otString)
+ arch->function_list()->AddByAddress(map_function->address(), ctVirtualization, 0, true, NULL);
+ }
+ ASSERT_EQ(arch->function_list()->count(), 2ul);
+ std::string file_name = pf.file_name()+".exe";
+ PEFile *f = pf.Clone(file_name.c_str());
+ CompileOptions options;
+ options.flags = cpMaximumProtection;
+ options.section_name = ".vmp";
+ ASSERT_TRUE(f->Compile(options));
+ delete f;
+ PEFile pf2(NULL);
+ ASSERT_EQ(pf2.Open(file_name.c_str(), foRead | foHeaderOnly), osSuccess);
+ ASSERT_EQ(pf2.count(), pf.count());
+ PEArchitecture &src = *pf.arch_pe();
+ PEArchitecture &dst = *pf2.arch_pe();
+ for (i = 0; i < src.fixup_list()->count(); i++) {
+ IFixup *src_fixup = src.fixup_list()->item(i);
+ IFixup *dst_fixup = src.fixup_list()->GetFixupByAddress(src_fixup->address());
+ EXPECT_EQ(src_fixup->address(), dst_fixup->address());
+ EXPECT_EQ(src_fixup->type(), dst_fixup->type());
+ EXPECT_EQ(src_fixup->size(), dst_fixup->size());
+ }
+ if (options.flags & cpResourceProtection) {
+ EXPECT_EQ(dst.resource_list()->count(), 1ul);
+ } else {
+ ASSERT_EQ(src.resource_list()->count(), dst.resource_list()->count());
+ for (i = 0; i < src.resource_list()->count(); i++) {
+ PEResource *src_resource = src.resource_list()->item(i);
+ PEResource *dst_resource = dst.resource_list()->item(i);
+ EXPECT_EQ(src_resource->count(), dst_resource->count());
+ EXPECT_EQ(src_resource->address(), dst_resource->address());
+ EXPECT_EQ(src_resource->size(), dst_resource->size());
+ EXPECT_EQ(src_resource->type(), dst_resource->type());
+ EXPECT_EQ(src_resource->name(), dst_resource->name());
+ }
+ }
+ // check AV buffer
+ ASSERT_EQ(dst.segment_list()->count(), 9ul);
+ ASSERT_TRUE(dst.AddressSeek(dst.segment_list()->item(6)->address()));
+ uint32_t sum = 0;
+ for (i = 0; i < 64; i++) {
+ sum += dst.ReadDWord();
+ }
+ EXPECT_EQ(sum, 0xB7896EB5);
+ // delete file from disk
+ pf2.Close();
+ remove(file_name.c_str());
+}
+
+TEST(PEFileTest, Pack)
+{
+ PEFile pf(NULL);
+
+ ASSERT_EQ(pf.Open("test-binaries/win32-app-delphi-i386", foRead), osSuccess);
+ PEArchitecture *arch = pf.arch_pe();
+ PESegment *section = arch->segment_list()->item(0);
+ Data data, props;
+ Packer packer;
+ size_t data_size = static_cast<size_t>(section->physical_size());
+ ASSERT_TRUE(packer.WriteProps(&props));
+ ASSERT_TRUE(arch->AddressSeek(section->address()));
+ ASSERT_TRUE(packer.Code(arch, data_size, &data));
+ Byte *dst = new Byte[data_size];
+
+ CLzmaDecoderState state;
+ EXPECT_EQ(LzmaDecodeProperties(&state.Properties, props.data(), (unsigned)props.size()), LZMA_RESULT_OK);
+ state.Probs = (CProb *)new Byte[LzmaGetNumProbs(&state.Properties) * sizeof(CProb)];
+ SizeT src_processed_size;
+ SizeT dst_processed_size;
+ EXPECT_EQ(LzmaDecode(&state, data.data(), -1, &src_processed_size, dst, -1, &dst_processed_size), LZMA_RESULT_OK);
+ delete [] state.Probs;
+ ASSERT_EQ(dst_processed_size, data_size);
+
+ arch->AddressSeek(section->address());
+ for (size_t i = 0; i < data_size; i++) {
+ EXPECT_EQ(dst[i], arch->ReadByte());
+ }
+ delete [] dst;
+}
+
+TEST(PEFileTest, CalcCheckSum)
+{
+ uint32_t sum;
+ ASSERT_TRUE(os::FileGetCheckSum("test-binaries/win32-app-delphi-i386", &sum));
+ EXPECT_EQ(sum, 0x000e4490ul);
+ ASSERT_TRUE(os::FileGetCheckSum("test-binaries/win64-app-msvc-amd64", &sum));
+ EXPECT_EQ(sum, 0x0000b8c9ul);
+}
+
+#ifndef DEMO
+#ifndef __APPLE__
+static bool execFile(const std::string &fileName, DWORD &exitCode)
+{
+ exitCode = 0xFFFFFFF;
+#ifdef VMP_GNU
+ int ret = system(("wine " + fileName).c_str());
+ if (ret != -1)
+ {
+ exitCode = DWORD(ret);
+ return true;
+ }
+ return false;
+#else
+ PROCESS_INFORMATION processInformation = { };
+ STARTUPINFOW startupInfo = { };
+ startupInfo.cb = sizeof(startupInfo);
+ os::unicode_string unicodeName = os::FromUTF8(fileName);
+
+ BOOL result = CreateProcessW(NULL, const_cast<wchar_t *>(unicodeName.c_str()),
+ NULL, NULL, FALSE,
+ NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW,
+ NULL, NULL, &startupInfo, &processInformation);
+
+ if (!result)
+ return false;
+
+ WaitForSingleObject(processInformation.hProcess, 10000);
+ result = GetExitCodeProcess(processInformation.hProcess, &exitCode);
+ if (exitCode == STILL_ACTIVE)
+ TerminateProcess(processInformation.hProcess, 0xFFFFFFFF);
+ CloseHandle(processInformation.hProcess);
+ CloseHandle(processInformation.hThread);
+
+ return (result && (exitCode != STILL_ACTIVE));
+#endif
+}
+
+/* seh.cpp:
+#include <windows.h>
+#include "VMProtectSDK.h"
+
+__declspec(noinline) void try1()
+{
+ printf("try 1\n");
+ try {
+ throw 1;
+ }
+ catch (int) {
+ printf("catch 1\n");
+ throw;
+ }
+ printf("end 1\n\n");
+}
+
+__declspec(noinline) void try2()
+{
+ printf("try 2\n");
+ PEXCEPTION_POINTERS info = NULL;
+ __try {
+ if (*reinterpret_cast<char *>(0xFACE) == 0)
+ return;
+ }
+ __except (info = GetExceptionInformation(), EXCEPTION_EXECUTE_HANDLER) {
+ printf("throw at %p\n", info->ExceptionRecord->ExceptionAddress);
+ }
+ printf("end 2\n\n");
+}
+
+int main()
+{
+ if (VMProtectIsDebuggerPresent(true))
+ printf("debugger detected\n");
+ if (VMProtectIsVirtualMachinePresent())
+ printf("virtual machine detected\n");
+
+ printf("try main\n");
+ try {
+ try1();
+ }
+ catch (...) {
+ printf("catch main\n");
+ }
+ printf("end main\n");
+ try2();
+
+ return 0;
+}
+*/
+
+TEST(PEFileTest, SEH_x32)
+{
+ PEFile pf(NULL);
+ ASSERT_EQ(pf.Open("test-binaries/seh-x86", foRead), osSuccess);
+ PEArchitecture *arch = pf.arch_pe();
+ arch->function_list()->AddByAddress(0x00401130, ctVirtualization, 0, true, NULL); // main
+ arch->function_list()->AddByAddress(0x00401000, ctUltra, 0, true, NULL); // try1
+ arch->function_list()->AddByAddress(0x00401070, ctMutation, 0, true, NULL); // try2
+ std::string file_name = pf.file_name() + ".exe";
+ PEFile *f = pf.Clone(file_name.c_str());
+ CompileOptions options;
+ options.flags = cpMaximumProtection;
+ options.section_name = ".vmp";
+ ASSERT_TRUE(f->Compile(options));
+ delete f;
+ DWORD ret;
+ ASSERT_TRUE(execFile(file_name, ret));
+ ASSERT_EQ(ret, 0u);
+}
+#endif
+#ifndef VMP_GNU
+TEST(PEFileTest, SEH_x64)
+{
+ PEFile pf(NULL);
+ ASSERT_EQ(pf.Open("test-binaries/seh-x64", foRead), osSuccess);
+ PEArchitecture *arch = pf.arch_pe();
+ arch->function_list()->AddByAddress(0x00000001400010A0, ctVirtualization, 0, true, NULL); // main
+ arch->function_list()->AddByAddress(0x0000000140001000, ctUltra, 0, true, NULL); // try1
+ arch->function_list()->AddByAddress(0x0000000140001040, ctMutation, 0, true, NULL); // try2
+ std::string file_name = pf.file_name() + ".exe";
+ PEFile *f = pf.Clone(file_name.c_str());
+ CompileOptions options;
+ options.flags = cpMaximumProtection;
+ options.section_name = ".vmp";
+ ASSERT_TRUE(f->Compile(options));
+ delete f;
+ DWORD ret;
+ ASSERT_TRUE(execFile(file_name, ret));
+ ASSERT_EQ(ret, 0u);
+}
+#endif
+#endif
diff --git a/unit-tests/precompiled.cc b/unit-tests/precompiled.cc
new file mode 100644
index 0000000..5f656a4
--- /dev/null
+++ b/unit-tests/precompiled.cc
@@ -0,0 +1 @@
+#include "precompiled.h"
diff --git a/unit-tests/precompiled.h b/unit-tests/precompiled.h
new file mode 100644
index 0000000..b375dcd
--- /dev/null
+++ b/unit-tests/precompiled.h
@@ -0,0 +1,17 @@
+#pragma once
+#ifndef UT_PCH
+#define UT_PCH
+
+#include "../core/precompiled.h"
+
+#ifdef WIN
+#include <windows.h>
+#include <crtdbg.h> /* Heap verifying */
+#elif MACOSX
+#define __ICONS__
+#include <Cocoa/Cocoa.h>
+#endif
+
+#include "gtest/gtest.h"
+
+#endif //UT_PCH \ No newline at end of file
diff --git a/unit-tests/test1.cc b/unit-tests/test1.cc
new file mode 100644
index 0000000..4aedef7
--- /dev/null
+++ b/unit-tests/test1.cc
@@ -0,0 +1,309 @@
+#include "../runtime/common.h"
+#include "../runtime/crypto.h"
+#include "../core/objects.h"
+#include "../core/osutils.h"
+#include "../core/streams.h"
+#include "../core/files.h"
+#include "../core/processors.h"
+#include "../core/intel.h"
+
+#include "testfile.h"
+
+static uint8_t test_data[] = "test data";
+const size_t TEST_DATA_SIZE = 9ul;
+
+TEST(AbstractStreamTest, FileStream_Test)
+{
+ bool status;
+ for (size_t bufSize = TEST_DATA_SIZE + 3; bufSize > 3; bufSize -= 3)
+ {
+ FileStream s(bufSize);
+ uint8_t buf[16];
+ size_t rc;
+ uint64_t rc1, rc2;
+
+ status = s.Open("test.bin", fmOpenReadWrite | fmShareDenyNone | fmCreate);
+ ASSERT_TRUE(status);
+ // Check .Write()
+ rc = s.Write(reinterpret_cast<const uint8_t*>(test_data), TEST_DATA_SIZE);
+ ASSERT_EQ(rc, TEST_DATA_SIZE);
+ // Check .Seek() with various origins
+ rc2 = s.Seek(1, soBeginning);
+ ASSERT_EQ(rc2, 1ull);
+ rc2 = s.Seek(2, soCurrent);
+ ASSERT_EQ(rc2, 3ull);
+ rc2 = s.Seek(1 - (int64_t)TEST_DATA_SIZE, soEnd);
+ ASSERT_EQ(rc2, 1ull);
+ // Check .Tell()
+ rc1 = s.Tell();
+ ASSERT_EQ(rc1, rc2);
+ // Check .Read(), validate data
+ rc = s.Read(buf, TEST_DATA_SIZE - 1);
+ ASSERT_EQ(rc, TEST_DATA_SIZE - 1);
+ ASSERT_EQ(0, memcmp(buf, &test_data[1], TEST_DATA_SIZE - 1)); //-V512
+ s.Seek(0, soBeginning);
+ rc = s.Read(buf, TEST_DATA_SIZE / 2);
+ ASSERT_EQ(rc, TEST_DATA_SIZE / 2);
+ ASSERT_EQ(0, memcmp(buf, &test_data[0], TEST_DATA_SIZE / 2)); //-V512
+ rc = s.Read(buf, TEST_DATA_SIZE / 2);
+ ASSERT_EQ(rc, TEST_DATA_SIZE / 2);
+ ASSERT_EQ(0, memcmp(buf, &test_data[TEST_DATA_SIZE / 2], TEST_DATA_SIZE / 2)); //-V512
+ // Check .GetSize()
+ rc2 = s.Size();
+ ASSERT_EQ(TEST_DATA_SIZE, rc2);
+ // Check .Resize
+ rc2 = s.Resize(2 * TEST_DATA_SIZE);
+ ASSERT_EQ(TEST_DATA_SIZE * 2, rc2);
+ rc2 = s.Seek(-((int64_t)TEST_DATA_SIZE), soEnd);
+ ASSERT_EQ(TEST_DATA_SIZE, rc2);
+ ASSERT_EQ(s.Size(), TEST_DATA_SIZE * 2);
+ rc = s.Write(test_data, TEST_DATA_SIZE);
+ ASSERT_EQ(rc, TEST_DATA_SIZE);
+ rc = s.Write("\n12", 4);
+ ASSERT_EQ(rc, 4ul);
+ rc2 = s.Seek(TEST_DATA_SIZE, soBeginning);
+ ASSERT_EQ(rc2, TEST_DATA_SIZE);
+ std::string teststr;
+ ASSERT_EQ(s.ReadLine(teststr), true);
+ ASSERT_STREQ(teststr.c_str(), (const char *)test_data);
+ s.Close();
+ }
+}
+
+TEST(AbstractStreamTest, MemoryStream_Test)
+{
+ MemoryStream s;
+ uint8_t buf[16];
+ size_t rc;
+ uint64_t rc1, rc2;
+
+ // Check .Write()
+ rc = s.Write(reinterpret_cast<const uint8_t*>(test_data), TEST_DATA_SIZE);
+ ASSERT_EQ(rc, TEST_DATA_SIZE);
+ // Check .Seek() with various origins
+ rc2 = s.Seek(1, soBeginning);
+ ASSERT_EQ(rc2, 1ull);
+ rc2 = s.Seek(2, soCurrent);
+ ASSERT_EQ(rc2, 3ull);
+ rc2 = s.Seek(1 - (int64_t)TEST_DATA_SIZE, soEnd);
+ ASSERT_EQ(rc2, 1ull);
+ // Check .Tell()
+ rc1 = s.Tell();
+ ASSERT_EQ(rc1, rc2);
+ // Check .Read(), validate data
+ rc = s.Read(buf, TEST_DATA_SIZE - 1);
+ ASSERT_EQ(rc, TEST_DATA_SIZE - 1);
+ ASSERT_EQ(0, memcmp(buf, &test_data[1], TEST_DATA_SIZE - 1)); //-V512
+ // Check .GetSize()
+ rc2 = s.Size();
+ ASSERT_EQ(TEST_DATA_SIZE, rc2);
+}
+
+TEST(AbstractStreamTest, MemoryStream_Copy_Test)
+{
+ MemoryStream s1, s2;
+ uint8_t buf[16];
+ size_t rc;
+ uint64_t rc2;
+
+ rc = s1.Write(reinterpret_cast<const uint8_t*>(test_data), TEST_DATA_SIZE);
+ ASSERT_EQ(rc, TEST_DATA_SIZE);
+ rc2 = s1.Seek(0, soBeginning);
+ ASSERT_EQ(rc2, 0ull);
+ rc = s2.CopyFrom(s1, TEST_DATA_SIZE);
+ ASSERT_EQ(rc, TEST_DATA_SIZE);
+ rc2 = s2.Seek(1, soBeginning);
+ ASSERT_EQ(rc2, 1ull);
+ rc = s2.Read(buf, TEST_DATA_SIZE - 1);
+ ASSERT_EQ(rc, TEST_DATA_SIZE - 1);
+ ASSERT_EQ(0, memcmp(buf, &test_data[1], TEST_DATA_SIZE - 1)); //-V512
+}
+
+TEST(AbstractStreamTest, FileStream_Copy_Test)
+{
+ bool status;
+ for (size_t bufSize = TEST_DATA_SIZE + 3; bufSize > 3; bufSize -= 3)
+ {
+ FileStream s1(bufSize), s2(bufSize), s3(bufSize);
+ status = s1.Open("test1.bin", fmOpenReadWrite | fmShareDenyNone | fmCreate);
+ ASSERT_TRUE(status);
+ status = s2.Open("test2.bin", fmOpenReadWrite | fmShareDenyNone | fmCreate);
+ ASSERT_TRUE(status);
+ uint8_t buf[16];
+ size_t rc;
+ uint64_t rc2;
+
+ rc = s1.Write(reinterpret_cast<const uint8_t*>(test_data), TEST_DATA_SIZE);
+ ASSERT_EQ(rc, TEST_DATA_SIZE);
+ rc2 = s1.Seek(0, soBeginning);
+ ASSERT_EQ(rc2, 0ull);
+ rc = s2.CopyFrom(s1, TEST_DATA_SIZE);
+ ASSERT_EQ(rc, TEST_DATA_SIZE);
+ status = s3.Open("test2.bin", fmOpenRead | fmShareDenyNone);
+ ASSERT_TRUE(status);
+ ASSERT_STREQ(s3.ReadAll().c_str(), (const char *)(test_data));
+ rc2 = s2.Seek(1, soBeginning);
+ ASSERT_EQ(rc2, 1ull);
+ rc = s2.Read(buf, TEST_DATA_SIZE - 1);
+ ASSERT_EQ(rc, TEST_DATA_SIZE - 1);
+ ASSERT_EQ(0, memcmp(buf, &test_data[1], TEST_DATA_SIZE - 1)); //-V512
+ s1.Close();
+ s2.Close();
+ s3.Close();
+ }
+}
+
+TEST(Demangle, Demangle_Test)
+{
+ const struct {
+ const char *mangled;
+ const char *demangled;
+ } names[] = {
+ // Check some names from Qt.
+ {"?newCol@QColorPicker@?A0x3be3cb80@@QEAAXHH@Z", "`anonymous namespace'::QColorPicker::newCol(int,int)"},
+ {"_ZN9QSettings10beginGroupERK7QString", "QSettings::beginGroup(QString const&)"},
+ {"_ZNK10QTableView14verticalHeaderEv", "QTableView::verticalHeader() const"},
+ {"_ZNK12QTableWidget20horizontalHeaderItemEi", "QTableWidget::horizontalHeaderItem(int) const"},
+
+ // Apple names.
+ {"St9bad_alloc", "std::bad_alloc"},
+ {"_ZN1f1fE", "f::f"},
+ {"_Z1fv", "f()"},
+ {"_Z1fi", "f(int)"},
+ {"_Z3foo3bar", "foo(bar)"},
+ {"_Zrm1XS_", "operator%(X, X)"},
+ {"_ZplR1XS0_", "operator+(X&, X&)"},
+ {"_ZlsRK1XS1_", "operator<<(X const&, X const&)"},
+ {"_ZN3FooIA4_iE3barE", "Foo<int [4]>::bar"},
+ {"_Z1fIiEvi", "void f<int>(int)"},
+ {"_Z5firstI3DuoEvS0_", "void first<Duo>(Duo)"},
+ {"_Z5firstI3DuoEvT_", "void first<Duo>(Duo)"},
+ {"_Z3fooIiFvdEiEvv", "void foo<int, void (double), int>()"},
+ {"_ZN1N1fE", "N::f"},
+ {"_ZN6System5Sound4beepEv", "System::Sound::beep()"},
+ {"_ZN5Arena5levelE", "Arena::level"},
+ {"_ZN5StackIiiE5levelE", "Stack<int, int>::level"},
+ {"_Z1fI1XEvPVN1AIT_E1TE", "void f<X>(A<X>::T volatile*)"},
+ {"_ZngILi42EEvN1AIXplT_Li2EEE1TE", "void operator-<42>(A<(42)+(2)>::T)"},
+ {"_Z4makeI7FactoryiET_IT0_Ev", "Factory<int> make<Factory, int>()"},
+ {"_Z3foo5Hello5WorldS0_S_", "foo(Hello, World, World, Hello)"},
+ {"_Z3fooPM2ABi", "foo(int AB::**)"},
+ {"_ZlsRSoRKSs", "operator<<(std::ostream&, std::string const&)"},
+ {"_ZTI7a_class", "typeinfo for a_class"},
+ {"U4_farrVKPi", "int* const volatile restrict _far"},
+ {"_Z3fooILi2EEvRAplT_Li1E_i", "void foo<2>(int (&) [(2)+(1)])"},
+ {"_Z1fM1AKFvvE", "f(void (A::*)() const)"},
+ {"_Z3fooc", "foo(char)"},
+ {"2CBIL_Z3foocEE", "CB<foo(char)>"},
+ {"2CBIL_Z7IsEmptyEE", "CB<IsEmpty>"},
+ {"_ZZN1N1fEiE1p", "N::f(int)::p"},
+ {"_ZZN1N1fEiEs", "N::f(int)::string literal"},
+ {"_Z1fPFvvEM1SFvvE", "f(void (*)(), void (S::*)())"},
+ {"_ZN1N1TIiiE2mfES0_IddE", "N::T<int, int>::mf(N::T<double, double>)"},
+ {"_ZSt5state", "std::state"},
+ {"_ZNSt3_In4wardE", "std::_In::ward"},
+ {"_Z1fKPFiiE", "f(int (* const)(int))"},
+ {"_Z1fAszL_ZZNK1N1A1fEvE3foo_0E_i", "f(int [sizeof (N::A::f() const::foo)])"},
+ {"_Z1fA37_iPS_", "f(int [37], int (*) [37])"},
+ {"_Z1fM1AFivEPS0_", "f(int (A::*)(), int (*)())"},
+ {"_Z1fPFPA1_ivE", "f(int (*(*)()) [1])"},
+ {"_Z1fPKM1AFivE", "f(int (A::* const*)())"},
+ {"_Z1jM1AFivEPS1_", "j(int (A::*)(), int (A::**)())"},
+ {"_Z1sPA37_iPS0_", "s(int (*) [37], int (**) [37])"},
+ {"_Z3fooA30_A_i", "foo(int [30][])"},
+ {"_Z3kooPA28_A30_i", "koo(int (*) [28][30])"},
+ {"_ZlsRKU3fooU4bart1XS0_", "operator<<(X bart foo const&, X bart)"},
+ {"_ZlsRKU3fooU4bart1XS2_", "operator<<(X bart foo const&, X bart foo const)"},
+ {"_Z1fM1AKFivE", "f(int (A::*)() const)"},
+ {"_Z3absILi11EEvv", "void abs<11>()"},
+ {"_ZN1AIfEcvT_IiEEv", "A<float>::operator int<int>()"},
+ {"_ZN12libcw_app_ct10add_optionIS_EEvMT_FvPKcES3_cS3_S3_", "void libcw_app_ct::add_option<libcw_app_ct>(void (libcw_app_ct::*)(char const*), char const*, char, char const*, char const*)"},
+ {"_ZGVN5libcw24_GLOBAL__N_cbll.cc0ZhUKa23compiler_bug_workaroundISt6vectorINS_13omanip_id_tctINS_5debug32memblk_types_manipulator_data_ctEEESaIS6_EEE3idsE", "guard variable for libcw::(anonymous namespace)::compiler_bug_workaround<std::vector<libcw::omanip_id_tct<libcw::debug::memblk_types_manipulator_data_ct>, std::allocator<libcw::omanip_id_tct<libcw::debug::memblk_types_manipulator_data_ct> > > >::ids"},
+ {"_ZN5libcw5debug13cwprint_usingINS_9_private_12GlobalObjectEEENS0_17cwprint_using_tctIT_EERKS5_MS5_KFvRSt7ostreamE", "libcw::debug::cwprint_using_tct<libcw::_private_::GlobalObject> libcw::debug::cwprint_using<libcw::_private_::GlobalObject>(libcw::_private_::GlobalObject const&, void (libcw::_private_::GlobalObject::*)(std::ostream&) const)"},
+ {"_ZNKSt14priority_queueIP27timer_event_request_base_ctSt5dequeIS1_SaIS1_EE13timer_greaterE3topEv", "std::priority_queue<timer_event_request_base_ct*, std::deque<timer_event_request_base_ct*, std::allocator<timer_event_request_base_ct*> >, timer_greater>::top() const"},
+ {"_ZNKSt15_Deque_iteratorIP15memory_block_stRKS1_PS2_EeqERKS5_", "std::_Deque_iterator<memory_block_st*, memory_block_st* const&, memory_block_st* const*>::operator==(std::_Deque_iterator<memory_block_st*, memory_block_st* const&, memory_block_st* const*> const&) const"},
+ {"_ZNKSt17__normal_iteratorIPK6optionSt6vectorIS0_SaIS0_EEEmiERKS6_", "std::__normal_iterator<option const*, std::vector<option, std::allocator<option> > >::operator-(std::__normal_iterator<option const*, std::vector<option, std::allocator<option> > > const&) const"},
+ {"_ZNSbIcSt11char_traitsIcEN5libcw5debug27no_alloc_checking_allocatorEE12_S_constructIPcEES6_T_S7_RKS3_", "char* std::basic_string<char, std::char_traits<char>, libcw::debug::no_alloc_checking_allocator>::_S_construct<char*>(char*, char*, libcw::debug::no_alloc_checking_allocator const&)"},
+ {"_Z1fI1APS0_PKS0_EvT_T0_T1_PA4_S3_M1CS8_", "void f<A, A*, A const*>(A, A*, A const*, A const* (*) [4], A const* (* C::*) [4])"},
+ {"_Z3fooiPiPS_PS0_PS1_PS2_PS3_PS4_PS5_PS6_PS7_PS8_PS9_PSA_PSB_PSC_", "foo(int, int*, int**, int***, int****, int*****, int******, int*******, int********, int*********, int**********, int***********, int************, int*************, int**************, int***************)"},
+ {"_ZSt1BISt1DIP1ARKS2_PS3_ES0_IS2_RS2_PS2_ES2_ET0_T_SB_SA_PT1_", "std::D<A*, A*&, A**> std::B<std::D<A*, A* const&, A* const*>, std::D<A*, A*&, A**>, A*>(std::D<A*, A* const&, A* const*>, std::D<A*, A* const&, A* const*>, std::D<A*, A*&, A**>, A**)"},
+ {"_X11TransParseAddress", "_X11TransParseAddress"},
+ {"_ZNSt13_Alloc_traitsISbIcSt18string_char_traitsIcEN5libcw5debug9_private_17allocator_adaptorIcSt24__default_alloc_templateILb0ELi327664EELb1EEEENS5_IS9_S7_Lb1EEEE15_S_instancelessE", "std::_Alloc_traits<std::basic_string<char, std::string_char_traits<char>, libcw::debug::_private_::allocator_adaptor<char, std::__default_alloc_template<false, 327664>, true> >, libcw::debug::_private_::allocator_adaptor<std::basic_string<char, std::string_char_traits<char>, libcw::debug::_private_::allocator_adaptor<char, std::__default_alloc_template<false, 327664>, true> >, std::__default_alloc_template<false, 327664>, true> >::_S_instanceless"},
+ {"_GLOBAL__I__Z2fnv", "global constructors keyed to fn()"},
+ {"_Z1rM1GFivEMS_KFivES_M1HFivES1_4whatIKS_E5what2IS8_ES3_", "r(int (G::*)(), int (G::*)() const, G, int (H::*)(), int (G::*)(), what<G const>, what2<G const>, int (G::*)() const)"},
+ {"_Z10hairyfunc5PFPFilEPcE", "hairyfunc5(int (*(*)(char*))(long))"},
+ {"_Z1fILi1ELc120EEv1AIXplT_cviLd810000000000000000703DAD7A370C5EEE", "void f<1, (char)120>(A<(1)+((int)((double)[810000000000000000703DAD7A370C5]))>)"},
+ {"_Z1fILi1EEv1AIXplT_cvingLf3f800000EEE", "void f<1>(A<(1)+((int)(-((float)[3f800000])))>)"},
+ {"_ZNK11__gnu_debug16_Error_formatter14_M_format_wordImEEvPciPKcT_", "void __gnu_debug::_Error_formatter::_M_format_word<unsigned long>(char*, int, char const*, unsigned long) const"},
+ {"_ZSt18uninitialized_copyIN9__gnu_cxx17__normal_iteratorIPSt4pairISsPFbP6sqlitePPcEESt6vectorIS9_SaIS9_EEEESE_ET0_T_SG_SF_", "__gnu_cxx::__normal_iterator<std::pair<std::string, bool (*)(sqlite*, char**)>*, std::vector<std::pair<std::string, bool (*)(sqlite*, char**)>, std::allocator<std::pair<std::string, bool (*)(sqlite*, char**)> > > > std::uninitialized_copy<__gnu_cxx::__normal_iterator<std::pair<std::string, bool (*)(sqlite*, char**)>*, std::vector<std::pair<std::string, bool (*)(sqlite*, char**)>, std::allocator<std::pair<std::string, bool (*)(sqlite*, char**)> > > >, __gnu_cxx::__normal_iterator<std::pair<std::string, bool (*)(sqlite*, char**)>*, std::vector<std::pair<std::string, bool (*)(sqlite*, char**)>, std::allocator<std::pair<std::string, bool (*)(sqlite*, char**)> > > > >(__gnu_cxx::__normal_iterator<std::pair<std::string, bool (*)(sqlite*, char**)>*, std::vector<std::pair<std::string, bool (*)(sqlite*, char**)>, std::allocator<std::pair<std::string, bool (*)(sqlite*, char**)> > > >, __gnu_cxx::__normal_iterator<std::pair<std::string, bool (*)(sqlite*, char**)>*, std::vector<std::pair<std::string, bool (*)(sqlite*, char**)>, std::allocator<std::pair<std::string, bool (*)(sqlite*, char**)> > > >, __gnu_cxx::__normal_iterator<std::pair<std::string, bool (*)(sqlite*, char**)>*, std::vector<std::pair<std::string, bool (*)(sqlite*, char**)>, std::allocator<std::pair<std::string, bool (*)(sqlite*, char**)> > > >)"},
+ {"_Z1fP1cIPFiiEE", "f(c<int (*)(int)>*)"},
+ {"_Z4dep9ILi3EEvP3fooIXgtT_Li2EEE", "void dep9<3>(foo<((3)>(2))>*)"},
+ {"_ZStltI9file_pathSsEbRKSt4pairIT_T0_ES6_", "bool std::operator< <file_path, std::string>(std::pair<file_path, std::string> const&, std::pair<file_path, std::string> const&)"},
+ {"_Z9hairyfuncM1YKFPVPFrPA2_PM1XKFKPA3_ilEPcEiE", "hairyfunc(int (* const (X::** (* restrict (* volatile* (Y::*)(int) const)(char*)) [2])(long) const) [3])"},
+ {"_Z1fILin1EEvv", "void f<-1>()"},
+ {"_ZNSdD0Ev", "std::basic_iostream<char, std::char_traits<char> >::~basic_iostream()"},
+ {"_ZNK15nsBaseHashtableI15nsUint32HashKey8nsCOMPtrI4IFooEPS2_E13EnumerateReadEPF15PLDHashOperatorRKjS4_PvES9_", "nsBaseHashtable<nsUint32HashKey, nsCOMPtr<IFoo>, IFoo*>::EnumerateRead(PLDHashOperator (*)(unsigned int const&, IFoo*, void*), void*) const"},
+ {"_ZNK1C1fIiEEPFivEv", "int (*C::f<int>() const)()"},
+ {"_ZZ3BBdI3FooEvvENK3Fob3FabEv", "BBd<Foo>()::Fob::Fab() const"},
+ {"_ZZZ3BBdI3FooEvvENK3Fob3FabEvENK3Gob3GabEv", "BBd<Foo>()::Fob::Fab() const::Gob::Gab() const"},
+ {"_ZNK5boost6spirit5matchI13rcs_deltatextEcvMNS0_4impl5dummyEFvvEEv", "boost::spirit::match<rcs_deltatext>::operator void (boost::spirit::impl::dummy::*)()() const"},
+ {"_Z3fooIA6_KiEvA9_KT_rVPrS4_", "void foo<int const [6]>(int const [9][6], int restrict const (* volatile restrict) [9][6])"},
+ {"_Z3fooIA3_iEvRKT_", "void foo<int [3]>(int const (&) [3])"},
+ {"_Z3fooIPA3_iEvRKT_", "void foo<int (*) [3]>(int (* const&) [3])"},
+ {"_ZN13PatternDriver23StringScalarDeleteValueC1ERKNS_25ConflateStringScalarValueERKNS_25AbstractStringScalarValueERKNS_12TemplateEnumINS_12pdcomplementELZNS_16complement_namesEELZNS_14COMPLEMENTENUMEEEE", "PatternDriver::StringScalarDeleteValue::StringScalarDeleteValue(PatternDriver::ConflateStringScalarValue const&, PatternDriver::AbstractStringScalarValue const&, PatternDriver::TemplateEnum<PatternDriver::pdcomplement, PatternDriver::complement_names, PatternDriver::COMPLEMENTENUM> const&)"},
+ {"ALsetchannels", "ALsetchannels"},
+ {"_Z4makeI7FactoryiET_IT0_Ev", "Factory<int> make<Factory, int>()"},
+ {"_Z1fM1AKiPKS1_", "f(int const A::*, int const A::* const*)"},
+ {"_ZSA", "_ZSA"},
+ {"_ZN1fIL_", "_ZN1fIL_"},
+ {"_Za", "_Za"},
+ {"_ZNSA", "_ZNSA"},
+ {"_ZNT", "_ZNT"},
+ {"_Z1aMark", "_Z1aMark"},
+ {"_ZL3foo_2", "foo"},
+ {"_ZZL3foo_2vE4var1", "foo()::var1"},
+ {"_ZZL3foo_2vE4var1_0", "foo()::var1"},
+ {"_ZZN7myspaceL3foo_1EvEN11localstruct1fEZNS_3fooEvE16otherlocalstruct", "myspace::foo()::localstruct::f(myspace::foo()::otherlocalstruct)"},
+
+ // Check some names from MFC.
+ {"?InitWorkspacesCollection@CDaoWorkspace@@IAEXXZ", "CDaoWorkspace::InitWorkspacesCollection(void)"},
+ {"?Invoke@XEventSink@COleControlSite@@UAGJJABU_GUID@@KGPAUtagDISPPARAMS@@PAUtagVARIANT@@PAUtagEXCEPINFO@@PAI@Z",
+ "COleControlSite::XEventSink::Invoke(long,struct _GUID const &,unsigned long,unsigned short,struct tagDISPPARAMS *,struct tagVARIANT *,struct tagEXCEPINFO *,unsigned int *)"},
+ {"?IsNullValue@CDaoFieldExchange@@SGHPAXK@Z", "CDaoFieldExchange::IsNullValue(void *,unsigned long)"},
+ {"??$?0VQObject@@@?$QWeakPointer@VQObject@@@@AEAA@PEAVQObject@@_N@Z", "QWeakPointer<class QObject>::<class QObject>::<class QObject>(class QObject *,bool)"},
+
+ // Check not mangled names
+ {"__SomeNotMangledName", "__SomeNotMangledName"}
+ };
+ size_t i;
+
+ for (i = 0; i < _countof(names); i++) {
+ const std::string actual = DemangleName(names[i].mangled).name();
+ const char *expected = names[i].demangled;
+ EXPECT_TRUE(actual.compare(expected) == 0) << actual << std::endl << expected;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ setlocale(LC_ALL, "");
+ int rc;
+#ifdef WIN
+ /* Set up heap verifying. */
+ _CrtSetDbgFlag(
+ _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) | _CRTDBG_LEAK_CHECK_DF);
+#elif MACOSX
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+#endif
+ std::cout << "Unit test application #1\n";
+ testing::InitGoogleTest(&argc, argv);
+ rc = RUN_ALL_TESTS();
+ remove("test.bin");
+ remove("test1.bin");
+ remove("test2.bin");
+
+#ifdef MACOSX
+ [pool release];
+#endif
+ return rc;
+}
diff --git a/unit-tests/testfile.h b/unit-tests/testfile.h
new file mode 100644
index 0000000..7100d9e
--- /dev/null
+++ b/unit-tests/testfile.h
@@ -0,0 +1,273 @@
+#ifndef TESTFILE_H
+#define TESTFILE_H
+
+template<class TTestConfig> class TestSegmentListT;
+
+template<class TTestConfig>
+class TestSegmentT : public TTestConfig::Segment
+{
+public:
+ explicit TestSegmentT(typename TTestConfig::SegmentList *owner, uint64_t address, uint32_t size, const char *name, uint32_t type)
+ : TTestConfig::Segment(owner), address_(address), size_(size), name_(name), type_(type), physical_size_(0), physical_offset_(0) {}
+ virtual uint64_t address() const { return address_; }
+ virtual uint64_t size() const { return size_; }
+ virtual uint32_t physical_offset() const { return physical_offset_; }
+ virtual uint32_t physical_size() const { return physical_size_; }
+ virtual std::string name() const { return name_; }
+ virtual uint32_t memory_type() const { return type_; }
+ void set_physical_size(uint32_t physical_size) { physical_size_ = physical_size; }
+ void set_physical_offset(uint32_t physical_offset) { physical_offset_ = physical_offset; }
+ virtual void update_type(uint32_t mt) { }
+ virtual uint32_t flags() const { return 0; }
+ virtual void Rebase(uint64_t delta_base) { address_ += delta_base; }
+ virtual TestSegmentT<TTestConfig> *Clone(ISectionList *owner) const { return new TestSegmentT<TTestConfig>(dynamic_cast<typename TTestConfig::SegmentList *>(owner), address_, size_, name_.c_str(), type_); }
+private:
+ uint64_t address_;
+ uint32_t size_;
+ std::string name_;
+ uint32_t type_;
+ uint32_t physical_size_;
+ uint32_t physical_offset_;
+};
+
+template<class TTestConfig>
+class TestSegmentListT : public TTestConfig::SegmentList
+{
+public:
+ explicit TestSegmentListT(typename TTestConfig::Architecture *owner)
+ : TTestConfig::SegmentList(owner) {}
+
+ TestSegmentT<TTestConfig> *Add(uint64_t address, uint32_t size, const char *name, uint32_t type)
+ {
+ TestSegmentT<TTestConfig> *seg = new TestSegmentT<TTestConfig>(this, address, size, name, type);
+ this->AddObject(seg);
+ return seg;
+ }
+};
+
+template<class TTestConfig>
+class TestExportListT : public TTestConfig::ExportList
+{
+public:
+ explicit TestExportListT(typename TTestConfig::Architecture *owner)
+ : TTestConfig::ExportList(owner) {}
+ virtual std::string name() const { return ""; }
+protected:
+ virtual typename TTestConfig::Export *Add(uint64_t /*address*/) { return NULL; }
+};
+
+template<class TTestConfig>
+class TestFixupT : public TTestConfig::Fixup
+{
+public:
+ explicit TestFixupT(typename TTestConfig::FixupList *owner);
+ virtual uint64_t address() const { return 0; }
+ virtual FixupType type() const { return ftUnknown; }
+ virtual OperandSize size() const { return osDWord; }
+ virtual void set_address(uint64_t /*address*/) { return; }
+ virtual void Rebase(IArchitecture & /*file*/, uint64_t /*delta_base*/) { return; }
+ virtual TestFixupT<TTestConfig> *Clone(IFixupList *owner) const { return new TestFixupT<TTestConfig>(reinterpret_cast<typename TTestConfig::FixupList *>(owner)); }
+};
+
+template<class TTestConfig>
+class TestFixupListT : public TTestConfig::FixupList
+{
+public:
+ explicit TestFixupListT()
+ : TTestConfig::FixupList() {}
+ virtual IFixup *AddDefault(OperandSize /*cpu_address_size*/, bool /*is_code*/)
+ {
+ TestFixupT<TTestConfig> *fixup = new TestFixupT<TTestConfig>(this);
+ this->AddObject(fixup);
+ return fixup;
+ }
+};
+
+template<class TTestConfig>
+class TestImportListT : public TTestConfig::ImportList
+{
+public:
+ explicit TestImportListT(typename TTestConfig::Architecture *owner)
+ : TTestConfig::ImportList(owner) {}
+protected:
+ virtual typename TTestConfig::Import *AddSDK() { return NULL; }
+};
+
+class TestMapFile : public MapFile
+{
+public:
+ bool ParseEx(const char *file_name, const std::vector<uint64_t> &segments, uint64_t time_stamp)
+ {
+ bool res = MapFile::Parse(file_name, segments);
+ set_time_stamp(time_stamp);
+ return res;
+ }
+};
+
+template<class TTestConfig>
+class TestArchitectureT : public TTestConfig::Architecture
+{
+public:
+ explicit TestArchitectureT(typename TTestConfig::File *owner, OperandSize cpu_address_size)
+ : TTestConfig::Architecture(owner, 0, -1), function_list_(NULL), cpu_address_size_(cpu_address_size), virtual_machine_list_(NULL)
+ {
+ segment_list_ = new TestSegmentListT<TTestConfig>(this);
+ export_list_ = new TestExportListT<TTestConfig>(this);
+ fixup_list_ = new TestFixupListT<TTestConfig>();
+ import_list_ = new TestImportListT<TTestConfig>(this);
+ time_stamp_ = 1;
+
+ function_list_ = new typename TTestConfig::FunctionList(this);
+ runtime_function_list_ = new typename TTestConfig::RuntimeFunctionList();
+ virtual_machine_list_ = new typename TTestConfig::VirtualMachineList();
+ }
+
+ virtual ~TestArchitectureT()
+ {
+ delete segment_list_;
+ delete export_list_;
+ delete function_list_;
+ delete fixup_list_;
+ delete import_list_;
+ delete virtual_machine_list_;
+ delete runtime_function_list_;
+ };
+
+ virtual std::string format_name() const { return "TEST"; }
+ virtual std::string name() const { return "TEST"; }
+ virtual uint32_t type() const { return 0; }
+ virtual OperandSize cpu_address_size() const { return cpu_address_size_; }
+ virtual uint64_t entry_point() const { return 0; };
+ virtual uint32_t segment_alignment() const { return 0x1000; }
+ virtual TestSegmentListT<TTestConfig> *segment_list() const { return segment_list_; }
+ virtual typename TTestConfig::SectionList *section_list() const { return NULL; }
+ virtual TestImportListT<TTestConfig> *import_list() const { return import_list_; }
+ virtual TestExportListT<TTestConfig> *export_list() const { return export_list_; }
+ virtual TestFixupListT<TTestConfig> *fixup_list() const { return fixup_list_; }
+ virtual typename TTestConfig::RelocationList *relocation_list() const { return NULL; }
+ virtual typename TTestConfig::ResourceList *resource_list() const { return NULL; }
+ virtual IFunctionList *function_list() const { return function_list_; }
+ virtual IVirtualMachineList *virtual_machine_list() const { return virtual_machine_list_; }
+ virtual typename TTestConfig::SEHandlerList *seh_handler_list() const { return NULL; }
+ virtual typename TTestConfig::RuntimeFunctionList *runtime_function_list() const { return runtime_function_list_; }
+ virtual uint64_t image_base() const { return 0; }
+ virtual CallingConvention calling_convention() const { return ccStdcall; }
+ virtual uint64_t time_stamp() const { return time_stamp_; }
+
+ void ReadTestMapFile(const char *file_name)
+ {
+ TestMapFile map_file;
+ std::vector<uint64_t> segments;
+ for (size_t i = 0; i < segment_list()->count(); i++) {
+ segments.push_back(segment_list()->item(i)->address());
+ }
+ if (std::find(segments.begin(), segments.end(), 0) == segments.end())
+ segments.insert(segments.begin(), 0);
+ if (map_file.ParseEx(file_name, segments, time_stamp()))
+ this->ReadMapFile(map_file);
+ this->map_function_list()->ReadFromFile(*this);
+ };
+ virtual void Save(CompileContext & /*c*/)
+ {
+ ISection *last_section = segment_list_->item(0);
+ uint64_t address = AlignValue(last_section->address() + last_section->size(), segment_alignment());
+ uint64_t pos = this->size();
+ auto *vmp_section = segment_list_->Add(address, -1, ".vmp", mtReadable | mtExecutable);
+ vmp_section->set_physical_size(-1);
+ vmp_section->set_physical_offset(static_cast<uint32_t>(pos));
+
+ for (size_t i = 0; i < function_list_->count(); i++) {
+ function_list_->item(i)->WriteToFile(*this);
+ }
+ };
+
+ bool Prepare(CompileContext &ctx)
+ {
+ ISectionList *seg_list = segment_list();
+ if (seg_list->count() == 0)
+ return false;
+
+ ISection *section = seg_list->item(seg_list->count() - 1);
+ ctx.manager->Add(AlignValue(section->address() + section->size(), segment_alignment()), -1, mtReadable | mtExecutable | mtWritable | mtNotPaged);
+
+ return true;
+ };
+protected:
+ virtual bool ReadHeader(uint32_t /*open_mode*/) { return true; }
+private:
+ TestSegmentListT<TTestConfig> *segment_list_;
+ TestExportListT<TTestConfig> *export_list_;
+ IFunctionList *function_list_;
+ TestFixupListT<TTestConfig> *fixup_list_;
+ TestImportListT<TTestConfig> *import_list_;
+ OperandSize cpu_address_size_;
+ IVirtualMachineList *virtual_machine_list_;
+ typename TTestConfig::RuntimeFunctionList *runtime_function_list_;
+ uint64_t time_stamp_;
+
+ // no copy ctr or assignment op
+ TestArchitectureT(const TestArchitectureT &);
+ TestArchitectureT &operator =(const TestArchitectureT &);
+};
+
+template<class TTestConfig>
+class TestFileT : public TTestConfig::File
+{
+public:
+ explicit TestFileT(OperandSize cpu_address_size)
+ : TTestConfig::File(NULL)
+ {
+ Add(cpu_address_size);
+ }
+
+ explicit TestFileT(const typename TTestConfig::File &src, const char *file_name)
+ : TTestConfig::File(src, file_name) {}
+
+ void OpenFromMemory(const void *buf, uint32_t len)
+ {
+ this->CloseStream();
+ this->stream_ = new MemoryStream;
+ /*size_t res = */this->stream_->Write(buf, len);
+
+ ISection *segment = item(0)->segment_list()->item(0);
+ uint8_t b = 0xcc;
+ for (size_t i = len; i < segment->physical_size(); i++) {
+ this->stream_->Write(&b, sizeof(b));
+ }
+
+ typename TTestConfig::FileHelper helper;
+ helper.Parse(*item(0));
+ }
+
+ TestArchitectureT<TTestConfig> *item(size_t index) const { return reinterpret_cast<TestArchitectureT<TTestConfig> *>(TTestConfig::File::item(index)); }
+
+ IArchitecture *Add(OperandSize cpu_address_size)
+ {
+ auto arch = new TestArchitectureT<TTestConfig>(this, cpu_address_size);
+ this->AddObject(arch);
+ return arch;
+ }
+
+ TestFileT *Clone(const char *file_name) const
+ {
+ TestFileT *file = new TestFileT(*this, file_name);
+ return file;
+ }
+
+protected:
+ virtual OpenStatus ReadHeader(uint32_t /*open_mode*/) { return osSuccess; };
+ virtual IFile *runtime() const { return NULL; }
+private:
+ std::string map_file_name_;
+};
+
+class TestLog: public ILog
+{
+public:
+ virtual void AddMessage(MessageType /*type*/, IObject * /*sender*/, const std::string & /*message*/) { return; }
+ virtual void StartProgress(const std::string & /*caption*/, unsigned long long /*max*/) { return; }
+ virtual void StepProgress(unsigned long long /*value*/ = 1ull, bool /*is_project*/ = false) { return; }
+ virtual void EndProgress() { return; }
+};
+
+#endif \ No newline at end of file
diff --git a/unit-tests/testfileil.h b/unit-tests/testfileil.h
new file mode 100644
index 0000000..3e9497f
--- /dev/null
+++ b/unit-tests/testfileil.h
@@ -0,0 +1,30 @@
+#include "testfile.h"
+struct ILTestConfig
+{
+ typedef ILFunctionList FunctionList;
+ typedef ILVirtualMachineList VirtualMachineList;
+ typedef ILFileHelper FileHelper;
+ typedef NETArchitecture Architecture;
+ typedef NETRuntimeFunctionList RuntimeFunctionList;
+ typedef PESegmentList SegmentList;
+ typedef NETImportList ImportList;
+ typedef NETExportList ExportList;
+ typedef BaseFixupList FixupList;
+ typedef PESegment Segment;
+ typedef BaseFixup Fixup;
+ typedef PESectionList SectionList;
+ typedef IRelocationList RelocationList;
+ typedef NETResourceList ResourceList;
+ typedef ISEHandlerList SEHandlerList;
+ typedef IImport Import;
+ typedef IExport Export;
+ typedef PEFile File;
+};
+
+typedef TestArchitectureT<ILTestConfig> TestArchitecture;
+typedef TestFileT<ILTestConfig> TestFile;
+typedef TestSegmentListT<ILTestConfig> TestSegmentList;
+typedef TestSegmentT<ILTestConfig> TestSegment;
+
+template<>
+inline TestFixupT<ILTestConfig>::TestFixupT(ILTestConfig::FixupList *owner) : ILTestConfig::Fixup(owner) {}
diff --git a/unit-tests/testfileintel.h b/unit-tests/testfileintel.h
new file mode 100644
index 0000000..1786c04
--- /dev/null
+++ b/unit-tests/testfileintel.h
@@ -0,0 +1,30 @@
+#include "testfile.h"
+struct IntelTestConfig
+{
+ typedef IntelFunctionList FunctionList;
+ typedef IntelVirtualMachineList VirtualMachineList;
+ typedef IntelFileHelper FileHelper;
+ typedef PEArchitecture Architecture;
+ typedef PERuntimeFunctionList RuntimeFunctionList;
+ typedef PESegmentList SegmentList;
+ typedef PEImportList ImportList;
+ typedef PEExportList ExportList;
+ typedef PEFixupList FixupList;
+ typedef PESegment Segment;
+ typedef PEFixup Fixup;
+ typedef PESectionList SectionList;
+ typedef PERelocationList RelocationList;
+ typedef PEResourceList ResourceList;
+ typedef PESEHandlerList SEHandlerList;
+ typedef PEImport Import;
+ typedef PEExport Export;
+ typedef PEFile File;
+};
+
+typedef TestArchitectureT<IntelTestConfig> TestArchitecture;
+typedef TestFileT<IntelTestConfig> TestFile;
+typedef TestSegmentListT<IntelTestConfig> TestSegmentList;
+typedef TestSegmentT<IntelTestConfig> TestSegment;
+
+template<>
+inline TestFixupT<IntelTestConfig>::TestFixupT(PEFixupList *owner) : IntelTestConfig::Fixup(owner, 0, ftUnknown) {}