aboutsummaryrefslogtreecommitdiff
path: root/examples/dotnet/forms_mixed
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dotnet/forms_mixed')
-rw-r--r--examples/dotnet/forms_mixed/AssemblyInfo.cpp21
-rw-r--r--examples/dotnet/forms_mixed/Form1.cpp95
-rw-r--r--examples/dotnet/forms_mixed/forms_mixed.vcxproj90
3 files changed, 206 insertions, 0 deletions
diff --git a/examples/dotnet/forms_mixed/AssemblyInfo.cpp b/examples/dotnet/forms_mixed/AssemblyInfo.cpp
new file mode 100644
index 0000000..1805707
--- /dev/null
+++ b/examples/dotnet/forms_mixed/AssemblyInfo.cpp
@@ -0,0 +1,21 @@
+// Assembly forms_mixed, Version 1.0.0.0
+
+using namespace System::Reflection;
+using namespace System::Runtime::CompilerServices;
+using namespace System::Runtime::Versioning;
+using namespace System::Runtime::InteropServices;
+using namespace System::Diagnostics;
+
+[assembly: AssemblyDescriptionAttribute("")];
+[assembly: AssemblyConfigurationAttribute("")];
+[assembly: AssemblyCompanyAttribute("")];
+[assembly: RuntimeCompatibilityAttribute(WrapNonExceptionThrows=true)];
+[assembly: AssemblyTrademarkAttribute("")];
+[assembly: CompilationRelaxations(8)];
+[assembly: AssemblyTitleAttribute("forms_mixed")];
+[assembly: AssemblyProductAttribute("forms_mixed")];
+[assembly: AssemblyCopyrightAttribute("Copyright © 2014")];
+[assembly: TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName=".NET Framework 4")];
+[assembly: ComVisibleAttribute(false)];
+[assembly: GuidAttribute("31c4f344-7d2d-4fcc-8cf5-3c6d368ad136")];
+[assembly: AssemblyFileVersionAttribute("1.0.0.0")];
diff --git a/examples/dotnet/forms_mixed/Form1.cpp b/examples/dotnet/forms_mixed/Form1.cpp
new file mode 100644
index 0000000..dadae49
--- /dev/null
+++ b/examples/dotnet/forms_mixed/Form1.cpp
@@ -0,0 +1,95 @@
+using namespace System;
+using namespace System::Drawing;
+using namespace System::Windows;
+using namespace System::Windows::Forms;
+using namespace System::Runtime::InteropServices;
+
+
+#pragma unmanaged
+#include "stdlib.h"
+bool CheckPassword(const char *pwd)
+{
+ __int64 val = _atoi64(pwd);
+ return (val% 0x11) == 13;
+}
+#pragma managed
+
+namespace forms_mixed
+{
+ public ref class Form1 : public Form
+ {
+ public:
+ Form1()
+ {
+ label1 = gcnew Label();
+ txtPassword = gcnew TextBox();
+ btnCheckPassword = gcnew Button();
+ Form::SuspendLayout();
+ label1->AutoSize = true;
+ label1->Location = Point(13, 13);
+ label1->Name = "label1";
+ label1->Size = System::Drawing::Size(0x38, 13);
+ label1->TabIndex = 0;
+ label1->Text = "Password:";
+ txtPassword->Location = Point(0x4b, 10);
+ txtPassword->Name = "txtPassword";
+ txtPassword->Size = System::Drawing::Size(0xc0, 20);
+ txtPassword->TabIndex = 1;
+ btnCheckPassword->DialogResult = Forms::DialogResult::OK;
+ btnCheckPassword->Location = Point(0x111, 8);
+ btnCheckPassword->Name = "btnCheckPassword";
+ btnCheckPassword->Size = System::Drawing::Size(0x62, 0x17);
+ btnCheckPassword->TabIndex = 2;
+ btnCheckPassword->Text = "Check password";
+ btnCheckPassword->UseVisualStyleBackColor = true;
+ btnCheckPassword->Click += gcnew EventHandler(this, &Form1::btnCheckPassword_Click);
+ Form::AcceptButton = btnCheckPassword;
+ Form::AutoScaleDimensions = System::Drawing::Size(6, 13);
+ Form::AutoScaleMode = Forms::AutoScaleMode::Font;
+ Form::ClientSize = System::Drawing::Size(0x180, 40);
+ Form::Controls->Add(btnCheckPassword);
+ Form::Controls->Add(txtPassword);
+ Form::Controls->Add(label1);
+ Form::Name = "Form1";
+ Text = "VMProtect test [FormsMixed]";
+ Form::ResumeLayout(false);
+ Form::PerformLayout();
+ }
+
+ private:
+ [VMProtect::Begin]
+ void btnCheckPassword_Click(Object^ sender, EventArgs^ e)
+ {
+ IntPtr pwd = Marshal::StringToCoTaskMemAnsi(txtPassword->Text);
+ try
+ {
+ if (CheckPassword((const char *)((void *)pwd)))
+ {
+ MessageBox::Show(VMProtect::SDK::DecryptString("Correct password"), VMProtect::SDK::DecryptString("Password check"), MessageBoxButtons::OK, MessageBoxIcon::Asterisk);
+ }
+ else
+ {
+ MessageBox::Show(VMProtect::SDK::DecryptString("Incorrect password"), VMProtect::SDK::DecryptString("Password check"), MessageBoxButtons::OK, MessageBoxIcon::Hand);
+ txtPassword->Focus();
+ }
+ } catch(...)
+ {
+ Marshal::FreeCoTaskMem(pwd);
+ throw;
+ }
+ }
+
+ Button^ btnCheckPassword;
+ System::ComponentModel::IContainer^ components;
+ Label^ label1;
+ TextBox^ txtPassword;
+ };
+}
+
+int __stdcall WinMain (void *hInstance, void *hPrevInstance, void *lpCmdLine, int nShowCmd)
+{
+ Application::EnableVisualStyles();
+ Application::SetCompatibleTextRenderingDefault(false);
+ Application::Run(gcnew forms_mixed::Form1());
+ return 0;
+}
diff --git a/examples/dotnet/forms_mixed/forms_mixed.vcxproj b/examples/dotnet/forms_mixed/forms_mixed.vcxproj
new file mode 100644
index 0000000..59f4221
--- /dev/null
+++ b/examples/dotnet/forms_mixed/forms_mixed.vcxproj
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{ED79A565-8639-4BCF-B4EB-1E4718FFBFDF}</ProjectGuid>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <Keyword>ManagedCProj</Keyword>
+ <RootNamespace>forms_mixed</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <CLRSupport>true</CLRSupport>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <CLRSupport>true</CLRSupport>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies />
+ <SubSystem>Windows</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies />
+ <SubSystem>Windows</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="AssemblyInfo.cpp" />
+ <ClCompile Include="Form1.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Configuration" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="VMProtect.SDK">
+ <HintPath>..\..\..\bin\VMProtect.SDK.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file