From: <Or...@us...> - 2008-05-28 10:29:11
|
Revision: 177 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=177&view=rev Author: Oracle_ Date: 2008-05-28 03:29:19 -0700 (Wed, 28 May 2008) Log Message: ----------- Modified Paths: -------------- ACMServer/branches/sharp tester/SourceTest/SourceTest.vcproj ACMServer/branches/sharp tester/tester/Program.cs ACMServer/branches/sharp tester/tester/tester.csproj Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.vcproj =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.vcproj 2008-05-28 09:14:28 UTC (rev 176) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.vcproj 2008-05-28 10:29:19 UTC (rev 177) @@ -6,7 +6,7 @@ ProjectGUID="{FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}" RootNamespace="SourceTest" Keyword="ManagedCProj" - TargetFrameworkVersion="196613" + TargetFrameworkVersion="131072" > <Platforms> <Platform Modified: ACMServer/branches/sharp tester/tester/Program.cs =================================================================== --- ACMServer/branches/sharp tester/tester/Program.cs 2008-05-28 09:14:28 UTC (rev 176) +++ ACMServer/branches/sharp tester/tester/Program.cs 2008-05-28 10:29:19 UTC (rev 177) @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.IO; using SourceTest; Modified: ACMServer/branches/sharp tester/tester/tester.csproj =================================================================== --- ACMServer/branches/sharp tester/tester/tester.csproj 2008-05-28 09:14:28 UTC (rev 176) +++ ACMServer/branches/sharp tester/tester/tester.csproj 2008-05-28 10:29:19 UTC (rev 177) @@ -10,7 +10,7 @@ <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>tester</RootNamespace> <AssemblyName>tester</AssemblyName> - <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> @@ -32,15 +32,6 @@ </PropertyGroup> <ItemGroup> <Reference Include="System" /> - <Reference Include="System.Core"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> - <Reference Include="System.Xml.Linq"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> - <Reference Include="System.Data.DataSetExtensions"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> </ItemGroup> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-06-03 15:55:31
|
Revision: 204 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=204&view=rev Author: Oracle_ Date: 2008-06-03 08:55:38 -0700 (Tue, 03 Jun 2008) Log Message: ----------- Added test library. Some new abilities was added to TSource. Modified Paths: -------------- ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp ACMServer/branches/sharp tester/SourceTest/SourceTest.h ACMServer/branches/sharp tester/SourceTest.sln ACMServer/branches/sharp tester/tester/Program.cs Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp 2008-06-02 21:41:52 UTC (rev 203) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp 2008-06-03 15:55:38 UTC (rev 204) @@ -55,40 +55,42 @@ FState=ssNone; FCompPath=gcnew String(""); FRunAll=true; +lib=LoadLibraryA("TestLibrary.dll"); +FSecurity=new TSecure(); init(); } TSource::~TSource() { +if (lib!=NULL) + FreeLibrary(lib); +delete FSecurity; final(); } void TSource::CheckCL() { - HMODULE lib=NULL; try { lock(); - lib=LoadLibrary((LPCWSTR)"CheckCodeLimitDLL"); if (lib==NULL) { if (FSrc->Length>FLim.CodeLimit) - { FCompResult.res=crCL; - FCompResult.Details+="Used std checker for Code Limit\n"; - } + FCompResult.Details+="Used std checker for Code Limit\n"; } else { - TCheckCL prc=(TCheckCL)GetProcAddress(lib,"CheckCL"); - String^ buf; - if (prc(FSrc,buf)) FCompResult.res=crCL; - FCompResult.Details+=buf; + TCheckSrc prc=(TCheckSrc)GetProcAddress(lib,"CheckCL"); + char* buf,*bufA; + if (prc(bufA=StrToArr(FSrc),FLim.CodeLimit,buf)) FCompResult.res=crCL; + FreeArr(bufA); + FCompResult.Details+=gcnew String(buf); + TFreeFunc prc2=(TFreeFunc)GetProcAddress(lib,"FreeChar"); + prc2(buf); } FState=ssCheckedCL; }__finally { - if (lib!=NULL) - FreeLibrary(lib); unlock(); } } @@ -98,7 +100,19 @@ try { lock(); - //MAIN SOURCE + if (lib==NULL) + { + FCompResult.Details+="No checker for DF\n"; + } else + { + TCheckSrc prc=(TCheckSrc)GetProcAddress(lib,"CheckDF"); + char* buf,*bufA; + if (prc(bufA=StrToArr(FSrc),(int)FLang,buf)) FCompResult.res=crDF; + FreeArr(bufA); + FCompResult.Details+=gcnew String(buf); + TFreeFunc prc2=(TFreeFunc)GetProcAddress(lib,"FreeChar"); + prc2(buf); + } FState=ssCheckedDF; }__finally { @@ -273,13 +287,11 @@ TCheckAnsRes TSource::CheckAnswer(int index,String^ output) { - HMODULE lib=NULL; try { lock(); TTest t; LoadTest(index,t); - lib=LoadLibrary((LPCWSTR)"CheckAnswerDLL"); if (lib==NULL) { if (output!=t.output) @@ -287,13 +299,14 @@ return carAC; } else { + char* buf1,*buf2,*buf3; TCheckAnswer prc=(TCheckAnswer)GetProcAddress(lib,"CheckAnswer"); - return prc(t.input,output,t.output); + TCheckAnsRes res=(TCheckAnsRes)prc(buf1=StrToArr(t.input),buf2=StrToArr(output),buf3=StrToArr(t.output)); + FreeArr(buf1);FreeArr(buf2);FreeArr(buf3); + return res; } }__finally { - if (lib!=NULL) - FreeLibrary(lib); unlock(); } } @@ -327,12 +340,9 @@ return FALSE; if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) return FALSE; - return TRUE; } - - void DeletePrivileges(HANDLE proc) { HANDLE hToken; @@ -426,7 +436,7 @@ SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOALIGNMENTFAULTEXCEPT|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX); - if (!CreateProcess(NULL,bufW=StrToArrW(FExePath),NULL,NULL,TRUE,CREATE_SUSPENDED|CREATE_NO_WINDOW,NULL,NULL,&si,&pi)) + if (!FSecurity->RunProcess(bufW=StrToArrW(FExePath),TRUE,CREATE_SUSPENDED|CREATE_NO_WINDOW,&si,&pi)) { FreeArr(bufW); it->points=0; @@ -471,6 +481,9 @@ it->Details="Size of output file excided OutputLimit"; break; } + QueryInformationJobObject(job,JobObjectBasicAccountingInformation,&acc,sizeof(acc),NULL); + if (lib==NULL) + { if ((int)(GetTickCount()-start)>FLim.RealTimeLimit) { TerminateJobObject(job,0); @@ -478,7 +491,6 @@ it->Details="Real time limit"; break; } - QueryInformationJobObject(job,JobObjectBasicAccountingInformation,&acc,sizeof(acc),NULL); if ((acc.ThisPeriodTotalKernelTime.QuadPart+acc.ThisPeriodTotalUserTime.QuadPart)>FLim.TimeLimit*10000) { TerminateJobObject(job,0); @@ -486,6 +498,25 @@ it->Details="Time Limit"; break; } + } else + { + TCheckLim prc=(TCheckLim)GetProcAddress(lib,"CheckTL"); + if (prc((int)(acc.ThisPeriodTotalKernelTime.QuadPart+acc.ThisPeriodTotalUserTime.QuadPart),(int)(FLim.TimeLimit*10000))) + { + TerminateJobObject(job,0); + it->res=trTL; + it->Details="Time Limit"; + break; + } + prc=(TCheckLim)GetProcAddress(lib,"CheckRTL"); + if (prc((int)(GetTickCount()-start),FLim.RealTimeLimit)) + { + TerminateJobObject(job,0); + it->res=trTL; + it->Details="Real time Limit"; + break; + } + } unsigned long len,key; HANDLE proc; @@ -674,5 +705,26 @@ } } +//------------------------------------------------------- +//-------------SECURITY CLASS---------------------------- +//------------------------------------------------------- + +TSecure::TSecure() +{ + +} + +TSecure::~TSecure() +{ + +} + +bool TSecure::RunProcess(LPWSTR lpCommandLine,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo,LPPROCESS_INFORMATION lpProcessInformation) +{ + if (CreateProcess(NULL,lpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags,NULL,NULL,lpStartupInfo,lpProcessInformation)) + return true; + return false; +} + }; Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.h =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.h 2008-06-02 21:41:52 UTC (rev 203) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.h 2008-06-03 15:55:38 UTC (rev 204) @@ -8,7 +8,7 @@ namespace SourceTest { - public ref struct TLimits + public ref struct TLimits { int OutputLimit; int TimeLimit; @@ -181,18 +181,35 @@ public enum TCheckAnsRes { - carAC, //accepted - carWA, //wrong answer - carIE, //internal error - carPE, //presentation error - carOE //output error + carAC=0, //accepted + carWA=1, //wrong answer + carIE=2, //internal error + carPE=3, //presentation error + carOE=4 //output error }; - typedef bool (*TCheckCL)(String^ src,String^ details); - typedef TCheckAnsRes (*TCheckAnswer)(String^ input, String^ output, String^ rightoutput); + public enum TLang + { + lCpp=0, + lPascal=1 + }; + typedef bool (*TCheckSrc)(char* src,int,char*& details); + typedef bool (*TCheckLim)(int,int); + typedef int (*TCheckAnswer)(char* input, char* output, char* rightoutput); + typedef void (*TFreeFunc)(char* buf); + public delegate void TTestHandler(int index, TResult^ res); + private class TSecure + { + private: + public: + TSecure(); + ~TSecure(); + bool RunProcess(LPWSTR lpCommandLine,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo,LPPROCESS_INFORMATION lpProcessInformation); + }; + public ref class TSource { private: @@ -200,7 +217,7 @@ String^ FExePath; String^ FProblemPath; String^ FCompPath; - String^ FTempPath; //this is the place were temp files will be created + String^ FTempPath; //this is the place where temporary files will be created bool FRunAll; TSourceState FState; TCompResult FCompResult; @@ -208,6 +225,16 @@ TSummary FSummary; TLimits FLim; TTestHandler^ FTestHandler; + TLang FLang; + TSecure *FSecurity; + HMODULE lib; //library that must export: + //bool CheckCL(char* src, int cl, char* details) - must check codelimit + //bool CheckDF(char* src, int lang, char* details) - must check DF + //bool CheckRTL(int usedrealtime, int realtimelimit) - must check RTL + //bool CheckTL(int usedtime, int timelimit) - must check TL + //int CheckAnswer(char* input, char* output, char* rightoutput) - checks WA,OE,PE + //void FreeChar(char* buf); - must free memory used by buf + //if there is no library called TestLibrary.dll then standart check is performed CRITICAL_SECTION* cs; //for multithreading void init() @@ -548,5 +575,37 @@ } } } + + property TLang Language + { + void set(TLang value) + { + try + { + lock(); + if (FState>=ssCheckedDF) + { + throw "Can not set Language if state is higher or equal ssCheckedDF"; + return; + } + FLang=value; + } __finally + { + unlock(); + } + } + + TLang get() + { + try + { + lock(); + return FLang; + }__finally + { + unlock(); + } + } + } }; } Modified: ACMServer/branches/sharp tester/SourceTest.sln =================================================================== --- ACMServer/branches/sharp tester/SourceTest.sln 2008-06-02 21:41:52 UTC (rev 203) +++ ACMServer/branches/sharp tester/SourceTest.sln 2008-06-03 15:55:38 UTC (rev 204) @@ -5,6 +5,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tester", "tester\tester.csproj", "{2D663DAB-3573-4CB6-95A0-2425635CFEC3}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLibrary", "TestLibrary\TestLibrary.vcproj", "{2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -35,6 +37,16 @@ {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Mixed Platforms.Build.0 = Release|Any CPU {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Win32.ActiveCfg = Release|Any CPU + {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Debug|Win32.ActiveCfg = Debug|Win32 + {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Debug|Win32.Build.0 = Debug|Win32 + {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Release|Any CPU.ActiveCfg = Release|Win32 + {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Release|Mixed Platforms.Build.0 = Release|Win32 + {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Release|Win32.ActiveCfg = Release|Win32 + {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: ACMServer/branches/sharp tester/tester/Program.cs =================================================================== --- ACMServer/branches/sharp tester/tester/Program.cs 2008-06-02 21:41:52 UTC (rev 203) +++ ACMServer/branches/sharp tester/tester/Program.cs 2008-06-03 15:55:38 UTC (rev 204) @@ -30,8 +30,8 @@ s.Close(); c.TempPath = temp; c.TestHandler += new TTestHandler(func); + c.Language = (TLang)1; c.ProcessAll(); - c.State = (TSourceState)6; Console.WriteLine("Compile result: {0}\nCompilation details: {1}\nUsed Time for compile: {2}", TSource.CompileResultToString(c.Summary.compres.res),c.Summary.compres.Details,c.Summary.compres.UsedTime); Console.WriteLine("Test result: {0}", TSource.TestResultToString(c.Summary.res.res)); Console.WriteLine("Points: {0}", c.Summary.res.points); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-06-03 15:58:06
|
Revision: 205 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=205&view=rev Author: Oracle_ Date: 2008-06-03 08:58:14 -0700 (Tue, 03 Jun 2008) Log Message: ----------- Added TestLibrary. Added Paths: ----------- ACMServer/branches/sharp tester/SourceTest/AdvAPI32.Lib here.txt ACMServer/branches/sharp tester/TestLibrary/ ACMServer/branches/sharp tester/TestLibrary/TestLibrary.cpp ACMServer/branches/sharp tester/TestLibrary/TestLibrary.def ACMServer/branches/sharp tester/TestLibrary/TestLibrary.h ACMServer/branches/sharp tester/TestLibrary/TestLibrary.vcproj ACMServer/branches/sharp tester/TestLibrary/dllmain.cpp ACMServer/branches/sharp tester/TestLibrary/stdafx.cpp ACMServer/branches/sharp tester/TestLibrary/stdafx.h ACMServer/branches/sharp tester/TestLibrary/targetver.h Added: ACMServer/branches/sharp tester/SourceTest/AdvAPI32.Lib here.txt =================================================================== Added: ACMServer/branches/sharp tester/TestLibrary/TestLibrary.cpp =================================================================== --- ACMServer/branches/sharp tester/TestLibrary/TestLibrary.cpp (rev 0) +++ ACMServer/branches/sharp tester/TestLibrary/TestLibrary.cpp 2008-06-03 15:58:14 UTC (rev 205) @@ -0,0 +1,58 @@ +// TestLibrary.cpp : Defines the exported functions for the DLL application. +// + +#include "stdafx.h" +#include "TestLibrary.h" +#include <new.h> +#include <stdio.h> + +TESTLIBRARY_API bool CheckCL(char* src, int cl, char*& details) +{ + details=new char[20]; + strcpy_s(details,20,"CheckCL from DLL\n"); + return ((int)strlen(src)>cl); +} + +TESTLIBRARY_API bool CheckDF(char* src, int lang, char*& details) +{ + details=new char[20]; + strcpy_s(details,20,"CheckDF from DLL"); + return false; +} + +TESTLIBRARY_API void FreeChar(char* buf) +{ + delete[] buf; +} + +TESTLIBRARY_API bool CheckRTL(int usedrealtime, int realtimelimit) +{ + return (usedrealtime>realtimelimit); +} + +TESTLIBRARY_API bool CheckTL(int usedtime, int timelimit) +{ + return (usedtime>timelimit); +} + +TESTLIBRARY_API int CheckAnswer(char* input, char* output, char* rightoutput) +{ + if (strcmp(output,rightoutput)==0) + return 0; + int curo=0; + for (int i=0;;i++,curo++) + { + if (output[curo]=='\0'&&rightoutput[i]!='\0') + return 1; + if (output[curo]!='\0'&&rightoutput[i]=='\0') + return 1; + if (output[curo]=='\0'&&rightoutput[i]=='\0') + return 3; + while ((output[curo]==' ')&&(output[curo]=='\n')&&(output[curo]=='\r')) + ++curo; + while ((rightoutput[i]==' ')&&(rightoutput[i]=='\n')&&(rightoutput[i]=='\r')) + ++i; + if (output[curo]!=rightoutput[i]) + return 1; + } +} Added: ACMServer/branches/sharp tester/TestLibrary/TestLibrary.def =================================================================== --- ACMServer/branches/sharp tester/TestLibrary/TestLibrary.def (rev 0) +++ ACMServer/branches/sharp tester/TestLibrary/TestLibrary.def 2008-06-03 15:58:14 UTC (rev 205) @@ -0,0 +1,8 @@ +LIBRARY "TestLibrary" +EXPORTS +CheckCL +CheckDF +FreeChar +CheckRTL +CheckTL +CheckAnswer \ No newline at end of file Added: ACMServer/branches/sharp tester/TestLibrary/TestLibrary.h =================================================================== --- ACMServer/branches/sharp tester/TestLibrary/TestLibrary.h (rev 0) +++ ACMServer/branches/sharp tester/TestLibrary/TestLibrary.h 2008-06-03 15:58:14 UTC (rev 205) @@ -0,0 +1,14 @@ + +#ifdef TESTLIBRARY_EXPORTS +#define TESTLIBRARY_API __declspec(dllexport) +#else +#define TESTLIBRARY_API __declspec(dllimport) +#endif + +TESTLIBRARY_API bool CheckCL(char* src, int cl, char*& details); +TESTLIBRARY_API bool CheckDF(char* src, int lang, char*& details); +TESTLIBRARY_API void FreeChar(char* buf); +TESTLIBRARY_API bool CheckRTL(int usedrealtime, int realtimelimit); +TESTLIBRARY_API bool CheckTL(int usedtime, int timelimit); +TESTLIBRARY_API int CheckAnswer(char* input, char* output, char* rightoutput); + Added: ACMServer/branches/sharp tester/TestLibrary/TestLibrary.vcproj =================================================================== --- ACMServer/branches/sharp tester/TestLibrary/TestLibrary.vcproj (rev 0) +++ ACMServer/branches/sharp tester/TestLibrary/TestLibrary.vcproj 2008-06-03 15:58:14 UTC (rev 205) @@ -0,0 +1,253 @@ +<?xml version="1.0" encoding="windows-1251"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="TestLibrary" + ProjectGUID="{2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}" + RootNamespace="TestLibrary" + Keyword="Win32Proj" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="2" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TESTLIBRARY_EXPORTS" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="2" + WarningLevel="3" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + LinkIncremental="2" + ModuleDefinitionFile="TestLibrary.def" + GenerateDebugInformation="true" + SubSystem="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="2" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;TESTLIBRARY_EXPORTS" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="2" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + LinkIncremental="1" + ModuleDefinitionFile="TestLibrary.def" + GenerateDebugInformation="true" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\dllmain.cpp" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + </File> + <File + RelativePath=".\stdafx.cpp" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="1" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="1" + /> + </FileConfiguration> + </File> + <File + RelativePath=".\TestLibrary.cpp" + > + </File> + <File + RelativePath=".\TestLibrary.def" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath=".\stdafx.h" + > + </File> + <File + RelativePath=".\targetver.h" + > + </File> + <File + RelativePath=".\TestLibrary.h" + > + </File> + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Added: ACMServer/branches/sharp tester/TestLibrary/dllmain.cpp =================================================================== --- ACMServer/branches/sharp tester/TestLibrary/dllmain.cpp (rev 0) +++ ACMServer/branches/sharp tester/TestLibrary/dllmain.cpp 2008-06-03 15:58:14 UTC (rev 205) @@ -0,0 +1,19 @@ +// dllmain.cpp : Defines the entry point for the DLL application. +#include "stdafx.h" + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + Added: ACMServer/branches/sharp tester/TestLibrary/stdafx.cpp =================================================================== --- ACMServer/branches/sharp tester/TestLibrary/stdafx.cpp (rev 0) +++ ACMServer/branches/sharp tester/TestLibrary/stdafx.cpp 2008-06-03 15:58:14 UTC (rev 205) @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// TestLibrary.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file Added: ACMServer/branches/sharp tester/TestLibrary/stdafx.h =================================================================== --- ACMServer/branches/sharp tester/TestLibrary/stdafx.h (rev 0) +++ ACMServer/branches/sharp tester/TestLibrary/stdafx.h 2008-06-03 15:58:14 UTC (rev 205) @@ -0,0 +1,16 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include <windows.h> + + + +// TODO: reference additional headers your program requires here Added: ACMServer/branches/sharp tester/TestLibrary/targetver.h =================================================================== --- ACMServer/branches/sharp tester/TestLibrary/targetver.h (rev 0) +++ ACMServer/branches/sharp tester/TestLibrary/targetver.h 2008-06-03 15:58:14 UTC (rev 205) @@ -0,0 +1,24 @@ +#pragma once + +// The following macros define the minimum required platform. The minimum required platform +// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run +// your application. The macros work by enabling all features available on platform versions up to and +// including the version specified. + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. +#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. +#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif + +#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. +#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-06-04 16:42:39
|
Revision: 213 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=213&view=rev Author: Oracle_ Date: 2008-06-04 09:42:41 -0700 (Wed, 04 Jun 2008) Log Message: ----------- Fixed CE. Modified Paths: -------------- ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp ACMServer/branches/sharp tester/SourceTest/SourceTest.h ACMServer/branches/sharp tester/SourceTest/SourceTest.vcproj ACMServer/branches/sharp tester/tester/Program.cs Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp 2008-06-04 13:08:31 UTC (rev 212) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp 2008-06-04 16:42:41 UTC (rev 213) @@ -3,29 +3,36 @@ #include "stdafx.h" #include <stdio.h> #include "SourceTest.h" +#include <LM.h> +#include <Aclapi.h> +using namespace System::IO; +using namespace System::Diagnostics; +const wchar_t USER_NAME[]={'T','e','s','t','i','n','g','U','s','e','r'}; +const wchar_t USER_PASSW[]={'U','S','E','R','1','2','3','4','5'}; + namespace SourceTest { char* StrToArr(String^ str) { - return (char*)Marshal::StringToHGlobalAnsi(str).ToPointer(); + return (char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str).ToPointer(); } wchar_t* StrToArrW(String^ str) { - return (wchar_t*)Marshal::StringToHGlobalUni(str).ToPointer(); + return (wchar_t*)System::Runtime::InteropServices::Marshal::StringToHGlobalUni(str).ToPointer(); } void FreeArr(char* buf) { - Marshal::FreeHGlobal(IntPtr(buf)); + System::Runtime::InteropServices::Marshal::FreeHGlobal(IntPtr(buf)); } void FreeArr(wchar_t* buf) { - Marshal::FreeHGlobal(IntPtr(buf)); + System::Runtime::InteropServices::Marshal::FreeHGlobal(IntPtr(buf)); } String^ ToStr(int x) @@ -337,12 +344,32 @@ tp.Privileges[0].Attributes = SE_PRIVILEGE_REMOVED; if ( !AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(TOKEN_PRIVILEGES),(PTOKEN_PRIVILEGES) NULL,(PDWORD) NULL) ) +{ + int x=GetLastError(); return FALSE; +} if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) return FALSE; return TRUE; } +BOOL AddPrivilege(HANDLE hToken,LPCTSTR lpszPrivilege) +{ +TOKEN_PRIVILEGES tp; +LUID luid; +if (!LookupPrivilegeValue( NULL,lpszPrivilege,&luid)) + return FALSE; +tp.PrivilegeCount = 1; +tp.Privileges[0].Luid = luid; +tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + +if ( !AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(TOKEN_PRIVILEGES),(PTOKEN_PRIVILEGES) NULL,(PDWORD) NULL) ) + return FALSE; +if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) + return FALSE; +return TRUE; +} + void DeletePrivileges(HANDLE proc) { HANDLE hToken; @@ -426,7 +453,6 @@ TTest t; LoadTest(index,t); - job=CreateJobObject(NULL,(LPWSTR)""); si.cb=sizeof(si); si.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; si.wShowWindow=FALSE; @@ -453,6 +479,7 @@ return ; } FreeArr(bufW); + job=CreateJobObject(NULL,NULL); mem.BasicLimitInformation.LimitFlags=JOB_OBJECT_LIMIT_PROCESS_MEMORY; mem.ProcessMemoryLimit=FLim.MemoryLimit; SetInformationJobObject(job,JobObjectExtendedLimitInformation,&mem,sizeof(mem)); @@ -466,10 +493,8 @@ SetInformationJobObject(job,JobObjectBasicUIRestrictions,&uilim,sizeof(uilim)); DeletePrivileges(pi.hProcess); - AssignProcessToJobObject(job,pi.hProcess); ResumeThread(pi.hThread); - DWORD start=GetTickCount(); while (true) @@ -512,7 +537,7 @@ if (prc((int)(GetTickCount()-start),FLim.RealTimeLimit)) { TerminateJobObject(job,0); - it->res=trTL; + it->res=trRTL; it->Details="Real time Limit"; break; } @@ -711,7 +736,27 @@ TSecure::TSecure() { + /*USER_INFO_1 ui; + NET_API_STATUS st; + ui.usri1_comment=NULL; + ui.usri1_flags=UF_SCRIPT|UF_PASSWD_CANT_CHANGE; + ui.usri1_home_dir=NULL; + ui.usri1_name=(LPWSTR)USER_NAME; + ui.usri1_password=(LPWSTR)USER_PASSW; + ui.usri1_priv=USER_PRIV_USER; + ui.usri1_script_path=NULL; + st=NetUserAdd(NULL,1,(LPBYTE)&ui,NULL); + if (st!=NERR_Success) + { + if (st==NERR_UserExists) + return; + throw "Can not create user!"; + } + DirectoryInfo^ fi = gcnew DirectoryInfo("C:\\"); + DirectorySecurity^ fs = gcnew DirectorySecurity("C:\\", AccessControlSections::All); + fs->SetAccessRule(gcnew FileSystemAccessRule("TestingUser",FileSystemRights::FullControl,AccessControlType::Deny)); + fi->SetAccessControl(fs);*/ } TSecure::~TSecure() @@ -721,9 +766,19 @@ bool TSecure::RunProcess(LPWSTR lpCommandLine,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo,LPPROCESS_INFORMATION lpProcessInformation) { - if (CreateProcess(NULL,lpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags,NULL,NULL,lpStartupInfo,lpProcessInformation)) - return true; - return false; + /*HANDLE token; + if (LogonUser((LPWSTR)USER_NAME,(LPWSTR)".",(LPWSTR)USER_PASSW,LOGON32_LOGON_INTERACTIVE,LOGON32_PROVIDER_DEFAULT,&token)) + { + if (CreateProcessAsUser(token,NULL,lpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags,NULL,NULL,lpStartupInfo,lpProcessInformation)) + { + CloseHandle(token); + return true; + } + CloseHandle(token); + }*/ + if (CreateProcess(NULL,lpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags,NULL,NULL,lpStartupInfo,lpProcessInformation)) + return true; + return false; } }; Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.h =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.h 2008-06-04 13:08:31 UTC (rev 212) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.h 2008-06-04 16:42:41 UTC (rev 213) @@ -4,7 +4,7 @@ #include <windows.h> using namespace System; using namespace System::Collections; -using namespace System::Runtime::InteropServices; +using namespace System::Security::AccessControl; namespace SourceTest { Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.vcproj =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.vcproj 2008-06-04 13:08:31 UTC (rev 212) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.vcproj 2008-06-04 16:42:41 UTC (rev 213) @@ -246,6 +246,10 @@ RelativePath=".\AdvAPI32.Lib" > </File> + <File + RelativePath=".\NetAPI32.Lib" + > + </File> </Files> <Globals> </Globals> Modified: ACMServer/branches/sharp tester/tester/Program.cs =================================================================== --- ACMServer/branches/sharp tester/tester/Program.cs 2008-06-04 13:08:31 UTC (rev 212) +++ ACMServer/branches/sharp tester/tester/Program.cs 2008-06-04 16:42:41 UTC (rev 213) @@ -32,6 +32,7 @@ c.TestHandler += new TTestHandler(func); c.Language = (TLang)1; c.ProcessAll(); + c.State = (TSourceState)6; Console.WriteLine("Compile result: {0}\nCompilation details: {1}\nUsed Time for compile: {2}", TSource.CompileResultToString(c.Summary.compres.res),c.Summary.compres.Details,c.Summary.compres.UsedTime); Console.WriteLine("Test result: {0}", TSource.TestResultToString(c.Summary.res.res)); Console.WriteLine("Points: {0}", c.Summary.res.points); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-06-05 20:07:38
|
Revision: 217 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=217&view=rev Author: Oracle_ Date: 2008-06-05 13:07:26 -0700 (Thu, 05 Jun 2008) Log Message: ----------- Fixed some bugs, added some comments. Modified Paths: -------------- ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp ACMServer/branches/sharp tester/SourceTest/SourceTest.h ACMServer/branches/sharp tester/TestLibrary/TestLibrary.cpp Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp 2008-06-05 14:54:51 UTC (rev 216) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp 2008-06-05 20:07:26 UTC (rev 217) @@ -8,34 +8,34 @@ #include <Userenv.h> using namespace System::IO; -const wchar_t USER_NAME[]={'T','e','s','t','i','n','g','U','s','e','r'}; -const wchar_t USER_PASSW[]={'U','S','E','R','1','2','3','4','5'}; +const wchar_t USER_NAME[]={'T','e','s','t','i','n','g','U','s','e','r'}; //username for testing +const wchar_t USER_PASSW[]={'U','S','E','R','1','2','3','4','5'}; //password of user for testing namespace SourceTest { -char* StrToArr(String^ str) +char* StrToArr(String^ str) //converts Managed String to C++ string to { return (char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str).ToPointer(); } -wchar_t* StrToArrW(String^ str) +wchar_t* StrToArrW(String^ str) //converts Managed String to array of Unicode symbols { return (wchar_t*)System::Runtime::InteropServices::Marshal::StringToHGlobalUni(str).ToPointer(); } -void FreeArr(char* buf) +void FreeArr(char* buf) //destroys C++ string { System::Runtime::InteropServices::Marshal::FreeHGlobal(IntPtr(buf)); } -void FreeArr(wchar_t* buf) +void FreeArr(wchar_t* buf) //destroys array of Unicode symbols { System::Runtime::InteropServices::Marshal::FreeHGlobal(IntPtr(buf)); } -String^ ToStr(int x) +String^ ToStr(int x) //fast convert integer to Managed String { char intg[15]; _itoa_s(x,intg,10); @@ -43,7 +43,7 @@ } -bool FileExists(String^ path) +bool FileExists(String^ path) //checks whether file exists or not { char* buf=StrToArr(path); OFSTRUCT of; @@ -64,7 +64,7 @@ FRunAll=true; lib=LoadLibraryA("TestLibrary.dll"); FSecurity=new TSecure(); -init(); +init(); //initializing of critical section } TSource::~TSource() @@ -72,15 +72,15 @@ if (lib!=NULL) FreeLibrary(lib); delete FSecurity; -final(); +final(); } -void TSource::CheckCL() +void TSource::CheckCL() //checking size of source { try { lock(); - if (lib==NULL) + if (lib==NULL) //no library was found { if (FSrc->Length>FLim.CodeLimit) FCompResult.res=crCL; @@ -102,12 +102,12 @@ } } -void TSource::CheckDF() +void TSource::CheckDF() //checking for DF in source { try { lock(); - if (lib==NULL) + if (lib==NULL) //no library was found { FCompResult.Details+="No checker for DF\n"; } else @@ -127,7 +127,7 @@ } } -void TSource::Compile() +void TSource::Compile() //compiles the source { PROCESS_INFORMATION pi;ZeroMemory(&pi,sizeof(pi)); STARTUPINFO si; ZeroMemory(&si,sizeof(si)); @@ -144,7 +144,7 @@ String^ outpath=gcnew String(FTempPath+"compoutput.txt"); FExePath=FTempPath+"source.exe"; - if (FileExists(FExePath)) + if (FileExists(FExePath)) //delete previsious source { DeleteFile((LPCTSTR)(bufW=StrToArrW(FExePath))); FreeArr(bufW); @@ -194,7 +194,7 @@ ReadFile(oup,compres,size,&len,NULL); CloseHandle(oup); - if (!FileExists(FExePath)) + if (!FileExists(FExePath)) //compilation error { FCompResult.res=crCE; FCompResult.Details+=gcnew String("EXE file not found\n")+gcnew String(compres); @@ -214,7 +214,7 @@ } } -void TSource::RunTests() +void TSource::RunTests() //runs all tests of problem { try { @@ -230,7 +230,7 @@ if (((TResult^)FRes[n-1])->res!=trAC) { FSummary.res->res=((TResult^)FRes[n-1])->res; - if (!FRunAll) break; + if (!FRunAll) break; } n++; } @@ -241,7 +241,7 @@ } } -void TSource::LoadTest(int index,TTest% test) +void TSource::LoadTest(int index,TTest% test) //loads test from file { FILE* inp,*oup,*points; char *bufA; @@ -292,14 +292,14 @@ } } -TCheckAnsRes TSource::CheckAnswer(int index,String^ output) +TCheckAnsRes TSource::CheckAnswer(int index,String^ output) //checks answer for test { try { lock(); TTest t; LoadTest(index,t); - if (lib==NULL) + if (lib==NULL) //lib was not found { if (output!=t.output) return carWA; @@ -318,22 +318,27 @@ } } -void TSource::ProcessAll() +void TSource::ProcessAll() //executes all actions needed to get Summary result for all tests { -CheckCL(); -if (FCompResult.res==crOK) - CheckDF(); else - return ; -if (FCompResult.res==crOK) - Compile(); else - return ; -(*FSummary.compres)=FCompResult; -if (FCompResult.res==crOK) - RunTests(); else - return ; +try +{ + CheckCL(); + if (FCompResult.res==crOK) + CheckDF(); else + return ; + if (FCompResult.res==crOK) + Compile(); else + return ; + if (FCompResult.res==crOK) + RunTests(); else + return ; +} __finally +{ + (*FSummary.compres)=FCompResult; } +} -BOOL DelPrivilege(HANDLE hToken,LPCTSTR lpszPrivilege) +BOOL DelPrivilege(HANDLE hToken,LPCTSTR lpszPrivilege) //deletes privilege from process token { TOKEN_PRIVILEGES tp; LUID luid; @@ -344,16 +349,13 @@ tp.Privileges[0].Attributes = SE_PRIVILEGE_REMOVED; if ( !AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(TOKEN_PRIVILEGES),(PTOKEN_PRIVILEGES) NULL,(PDWORD) NULL) ) -{ - int x=GetLastError(); return FALSE; -} if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) return FALSE; return TRUE; } -BOOL AddPrivilege(HANDLE hToken,LPCTSTR lpszPrivilege) +BOOL AddPrivilege(HANDLE hToken,LPCTSTR lpszPrivilege) //adds privilege to process token (in this version unused) { TOKEN_PRIVILEGES tp; LUID luid; @@ -370,7 +372,7 @@ return TRUE; } -void DeletePrivileges(HANDLE proc) +void DeletePrivileges(HANDLE proc) //deletes all privileges from process token { HANDLE hToken; try @@ -417,7 +419,7 @@ } } -void TSource::RunTest(int index) +void TSource::RunTest(int index) //runs one test { PROCESS_INFORMATION pi;ZeroMemory(&pi,sizeof(pi)); STARTUPINFO si;ZeroMemory(&si,sizeof(si)); @@ -462,7 +464,7 @@ SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOALIGNMENTFAULTEXCEPT|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX); - if (!FSecurity->RunProcess(bufW=StrToArrW(FExePath),TRUE,CREATE_SUSPENDED|CREATE_NO_WINDOW,&si,&pi)) + if (!FSecurity->RunProcess(bufW=StrToArrW(FExePath),TRUE,CREATE_SUSPENDED|CREATE_NO_WINDOW,&si,&pi,it->Details)) { FreeArr(bufW); it->points=0; @@ -470,11 +472,11 @@ if ((err==193)||(err==1455)) { it->res=trRE; - it->Details="Too large array"; + it->Details+=gcnew String("Too large array"); } else { it->res=trIE; - it->Details="Can not start process"; + it->Details+=gcnew String("Can not start process"); } return ; } @@ -503,7 +505,7 @@ { TerminateJobObject(job,0); it->res=trOL; - it->Details="Size of output file excided OutputLimit"; + it->Details+=gcnew String("Size of output file excided OutputLimit"); break; } QueryInformationJobObject(job,JobObjectBasicAccountingInformation,&acc,sizeof(acc),NULL); @@ -513,14 +515,14 @@ { TerminateJobObject(job,0); it->res=trRTL; - it->Details="Real time limit"; + it->Details+=gcnew String("Real time limit"); break; } if ((acc.ThisPeriodTotalKernelTime.QuadPart+acc.ThisPeriodTotalUserTime.QuadPart)>FLim.TimeLimit*10000) { TerminateJobObject(job,0); it->res=trTL; - it->Details="Time Limit"; + it->Details+=gcnew String("Time Limit"); break; } } else @@ -530,7 +532,7 @@ { TerminateJobObject(job,0); it->res=trTL; - it->Details="Time Limit"; + it->Details+=gcnew String("Time Limit"); break; } prc=(TCheckLim)GetProcAddress(lib,"CheckRTL"); @@ -538,7 +540,7 @@ { TerminateJobObject(job,0); it->res=trRTL; - it->Details="Real time Limit"; + it->Details+=gcnew String("Real time Limit"); break; } } @@ -556,18 +558,18 @@ if (code==5) { it->res=trDF; - it->Details="Access denied."; + it->Details+=gcnew String("Access denied."); } else if (code!=0) { it->res=trRE; - it->Details="Runtime error #"+ToStr((int)code); + it->Details+=gcnew String("Runtime error #"+ToStr((int)code)); } needbreak=true; break; case JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT: it->res=trML; - it->Details="Memory Limit"; + it->Details+=gcnew String("Memory Limit"); needbreak=true; break; case JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO: @@ -575,12 +577,12 @@ if (code==5) { it->res=trDF; - it->Details="Access denied."; + it->Details+=gcnew String("Access denied."); } else if (code!=0) { it->res=trRE; - it->Details="Runtime error #"+ToStr((int)code); + it->Details+=gcnew String("Runtime error #"+ToStr((int)code)); } needbreak=true; break; @@ -609,7 +611,7 @@ if (!FileExists(oupath)) { it->res=trWA; - it->Details="No output file"; + it->Details+=gcnew String("No output file"); return; } @@ -667,18 +669,23 @@ void TSource::ProcessTest(int index) { -CheckCL(); -if (FCompResult.res==crOK) - CheckDF(); else - return ; -if (FCompResult.res==crOK) - Compile(); else - return ; -(*FSummary.compres)=FCompResult; -if (FCompResult.res==crOK) - RunTest(index); else - return ; +try +{ + CheckCL(); + if (FCompResult.res==crOK) + CheckDF(); else + return ; + if (FCompResult.res==crOK) + Compile(); else + return ; + if (FCompResult.res==crOK) + RunTest(index); else + return ; +} __finally +{ + (*FSummary.compres)=FCompResult; } +} void TSource::LoadLimits() { @@ -759,8 +766,8 @@ TSecure::TSecure() { - SetUserObjectFullAccess( GetThreadDesktop(GetCurrentThreadId())); - SetUserObjectFullAccess( GetProcessWindowStation()); + SetUserObjectFullAccess( GetThreadDesktop(GetCurrentThreadId())); //needed for accessing from CreateProcessAsUser + SetUserObjectFullAccess( GetProcessWindowStation()); //needed for accessing from CreateProcessAsUser USER_INFO_1 ui; NET_API_STATUS st; @@ -771,22 +778,27 @@ ui.usri1_password=(LPWSTR)USER_PASSW; ui.usri1_priv=USER_PRIV_USER; ui.usri1_script_path=NULL; - st=NetUserAdd(NULL,1,(LPBYTE)&ui,NULL); + st=NetUserAdd(NULL,1,(LPBYTE)&ui,NULL); //trying to create new user if (st!=NERR_Success) { if (st==NERR_UserExists) - return; - throw "Can not create user!"; + return; //if user exists just do nothing + MessageBox(NULL,(LPCTSTR)"Can not create testing user - only unsecured mode",(LPCTSTR)"Warning",MB_ICONWARNING|MB_OK); + return; } array<DriveInfo^>^ drv=DriveInfo::GetDrives(); - for (int i=0;i<drv->Length;i++) + for (int i=0;i<drv->Length;i++) //for all drives set limitation if (drv[i]->DriveType==DriveType::Fixed) { - DirectoryInfo^ fi = gcnew DirectoryInfo(drv[i]->Name); - DirectorySecurity^ fs = gcnew DirectorySecurity(drv[i]->Name, AccessControlSections::All); - fs->SetAccessRule(gcnew FileSystemAccessRule("TestingUser",FileSystemRights::FullControl,AccessControlType::Deny)); - fi->SetAccessControl(fs); + DirectoryInfo^ fi = gcnew DirectoryInfo(drv[i]->Name); + DirectorySecurity^ fs = gcnew DirectorySecurity(drv[i]->Name, AccessControlSections::All); + fs->SetAccessRule(gcnew FileSystemAccessRule(gcnew String(USER_NAME),FileSystemRights::FullControl, + InheritanceFlags::ObjectInherit|InheritanceFlags::ContainerInherit, + PropagationFlags::None, + AccessControlType::Deny)); + fi->SetAccessControl(fs); } + } TSecure::~TSecure() @@ -794,11 +806,16 @@ } -bool TSecure::RunProcess(LPWSTR lpCommandLine,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo,LPPROCESS_INFORMATION lpProcessInformation) +bool TSecure::RunProcess(LPWSTR lpCommandLine,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo,LPPROCESS_INFORMATION lpProcessInformation, String^% Details) { HANDLE token=NULL,Token=NULL; wchar_t* env=NULL; if (LogonUser((LPWSTR)USER_NAME,(LPWSTR)".",(LPWSTR)USER_PASSW,LOGON32_LOGON_NETWORK,LOGON32_PROVIDER_DEFAULT,&Token)) + { + FileInfo^ fi=gcnew FileInfo(gcnew String(lpCommandLine)); + FileSecurity^ fs=gcnew FileSecurity(gcnew String(lpCommandLine),AccessControlSections::All); + fs->SetAccessRule(gcnew FileSystemAccessRule(gcnew String(USER_NAME),FileSystemRights::ExecuteFile,AccessControlType::Allow)); + fi->SetAccessControl(fs); if (DuplicateTokenEx(Token,TOKEN_ALL_ACCESS,NULL,SecurityImpersonation,TokenPrimary,&token)) if (ImpersonateLoggedOnUser(token)) if (CreateEnvironmentBlock((LPVOID*)&env,token,FALSE)) @@ -807,9 +824,10 @@ DestroyEnvironmentBlock(env); RevertToSelf(); CloseHandle(token); + Details="Secured process. Result details: "; return true; } - int x=GetLastError(); + } if (env!=NULL) DestroyEnvironmentBlock(env); RevertToSelf(); @@ -817,6 +835,7 @@ CloseHandle(token); if (Token!=NULL) CloseHandle(Token); + Details="Unsecured process. Result details: "; if (CreateProcess(NULL,lpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags,NULL,NULL,lpStartupInfo,lpProcessInformation)) return true; return false; Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.h =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.h 2008-06-05 14:54:51 UTC (rev 216) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.h 2008-06-05 20:07:26 UTC (rev 217) @@ -8,14 +8,25 @@ namespace SourceTest { + /* + To normally execute source you need to: + 1. Have privileges SE_ASSIGNPRIMARYTOKEN_NAME and SE_INCREASE_QUOTA_NAME + 2. Have HTFS file system + 3. Have .NET Framework 2.0 or higher + */ + + + ///<summary> + ///TLimits holds information about limits for process + ///</summary> public ref struct TLimits { - int OutputLimit; - int TimeLimit; - int MemoryLimit; - int RealTimeLimit; - int CompilationTimeLimit; - int CodeLimit; + int OutputLimit; //maximum size of output file + int TimeLimit; //maximum kernel time + int MemoryLimit; //maximum virtual memory usage + int RealTimeLimit; //maximum real time + int CompilationTimeLimit; //maximum time for compilation + int CodeLimit; //maximum source size TLimits() { @@ -48,6 +59,9 @@ return value; } }; + ///<summary> + ///TCompRes is all possible results of compilation + ///</summary> public enum TCompRes //result of compilation { @@ -59,6 +73,10 @@ crIE //internal error }; + ///<summary> + ///TRes is all possible results of running the source + ///</summary> + public enum TRes { trAC, //accepted @@ -74,14 +92,18 @@ trOE //output error }; + ///<summary> + ///TResult holds information about results of running the process + ///</summary> + public ref struct TResult { TRes res; - int points; - int UsedMemory; - int UsedTime; - int UsedRealTime; - String^ Details; + int points; //points earned during testing (each test has some points) points are stored in Points.txt (in test folder) + int UsedMemory; //memory peak during testing + int UsedTime; //kernel time used + int UsedRealTime; //real time used + String^ Details; //details of testing TResult() { @@ -115,11 +137,15 @@ } }; + ///<summary> + ///TCompResult holds information about compilation + ///</summary> + public ref struct TCompResult { - TCompRes res; - int UsedTime; - String^ Details; + TCompRes res; //result of compilation + int UsedTime; //time used for compilation + String^ Details; //details of compilation TCompResult(TCompResult% value) { res=value.res; @@ -142,18 +168,23 @@ return value; } }; + ///<summary> + ///TSourceState is all possible states of source during its testing + ///</summary> public enum TSourceState { - ssNone=0, - ssCheckedCL=1, - ssCheckedDF=2, - ssCompiled=3, - ssIsRunning=4, //for multithreading + ssNone=0, //no actions were taken + ssCheckedCL=1, //CodeLimit checked + ssCheckedDF=2, //source is checked for DF + ssCompiled=3, //source is compiled + ssIsRunning=4, //test is running ssTestComplete=5, //next test is gonna be tested ssFinish=6 //all tests is tested }; - + ///<summary> + ///TSummary holds information about total result of processing all tests + ///</summary> public ref struct TSummary { public: @@ -172,12 +203,17 @@ } }; - + ///<summary> + ///TTest holds information about one test + ///</summary> public ref struct TTest { - String^ input,^output; - int points; + String^ input,^output; //input and output of test + int points; //points for test }; + ///<summary> + ///TCheckAnsRes is all possible values, what can give CheckAnswer function from DLL + ///</summary> public enum TCheckAnsRes { @@ -188,12 +224,16 @@ carOE=4 //output error }; + ///<summary> + ///TLang is all possible languages of source (needed for CheckDF) + ///</summary> + public enum TLang { lCpp=0, lPascal=1 }; - + typedef bool (*TCheckSrc)(char* src,int,char*& details); typedef bool (*TCheckLim)(int,int); typedef int (*TCheckAnswer)(char* input, char* output, char* rightoutput); @@ -201,32 +241,39 @@ public delegate void TTestHandler(int index, TResult^ res); + ///<summary> + ///Class that takes part in security - it has to create a user and execute source in his security context + ///</summary> + private class TSecure { private: public: TSecure(); ~TSecure(); - bool RunProcess(LPWSTR lpCommandLine,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo,LPPROCESS_INFORMATION lpProcessInformation); + bool RunProcess(LPWSTR lpCommandLine,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo,LPPROCESS_INFORMATION lpProcessInformation,String^% Details); }; + ///<summary> + ///TSource is main class that incapsulates all information about source and it's testing + ///</summary> public ref class TSource { private: - String^ FSrc; - String^ FExePath; - String^ FProblemPath; - String^ FCompPath; + String^ FSrc; //text of source + String^ FExePath; //executable file + String^ FProblemPath; //path for problem + String^ FCompPath; //path for compiler String^ FTempPath; //this is the place where temporary files will be created - bool FRunAll; - TSourceState FState; - TCompResult FCompResult; - ArrayList FRes; - TSummary FSummary; - TLimits FLim; - TTestHandler^ FTestHandler; - TLang FLang; - TSecure *FSecurity; + bool FRunAll; //if true then all tests will run (no matter on errors) + TSourceState FState; //state of source + TCompResult FCompResult; //result of compilation + ArrayList FRes; //results of each test + TSummary FSummary; //summary results of all tests + TLimits FLim; //limits for testing + TTestHandler^ FTestHandler; //event, that occures when test is completed + TLang FLang; //language of source + TSecure *FSecurity; //security class HMODULE lib; //library that must export: //bool CheckCL(char* src, int cl, char* details) - must check codelimit //bool CheckDF(char* src, int lang, char* details) - must check DF @@ -265,11 +312,11 @@ void CheckDF(); void Compile(); void RunTests(); //all tests - void RunTest(int index); + void RunTest(int index); //only one test TCheckAnsRes CheckAnswer(int index,String^ output); void ProcessAll(); //gets result for all tests void ProcessTest(int index); //gets result for only 1 test - void LoadTest(int index,TTest% test); + void LoadTest(int index,TTest% test); //load test from file void LoadLimits(); //loads limits from a file Limits.txt static String^ TestResultToString(TRes res); static String^ CompileResultToString(TCompRes res); Modified: ACMServer/branches/sharp tester/TestLibrary/TestLibrary.cpp =================================================================== --- ACMServer/branches/sharp tester/TestLibrary/TestLibrary.cpp 2008-06-05 14:54:51 UTC (rev 216) +++ ACMServer/branches/sharp tester/TestLibrary/TestLibrary.cpp 2008-06-05 20:07:26 UTC (rev 217) @@ -14,7 +14,7 @@ TESTLIBRARY_API bool CheckDF(char* src, int lang, char*& details) { details=new char[20]; - strcpy_s(details,20,"CheckDF from DLL"); + strcpy_s(details,20,"CheckDF from DLL\n"); return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-06-07 19:52:46
|
Revision: 227 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=227&view=rev Author: Oracle_ Date: 2008-06-07 12:51:51 -0700 (Sat, 07 Jun 2008) Log Message: ----------- Added Details to CheckAnswer procedure from DLL. Modified Paths: -------------- ACMServer/branches/sharp tester/ReadMe.txt ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp ACMServer/branches/sharp tester/SourceTest/SourceTest.h ACMServer/branches/sharp tester/TestLibrary/TestLibrary.cpp ACMServer/branches/sharp tester/TestLibrary/TestLibrary.h Modified: ACMServer/branches/sharp tester/ReadMe.txt =================================================================== --- ACMServer/branches/sharp tester/ReadMe.txt 2008-06-07 14:14:12 UTC (rev 226) +++ ACMServer/branches/sharp tester/ReadMe.txt 2008-06-07 19:51:51 UTC (rev 227) @@ -26,13 +26,13 @@ \xF6\xE5 \xF8\xEB\xFF\xF5 \xE4\xEE \xF1\xEE\xF0\xF1\xE0, \xE0 \xE4\xF0\xF3\xE3\xE8\xE9 - \xF6\xE5 \xF8\xEB\xFF\xF5, \xE4\xE5 \xEF\xEE\xE2\xE8\xED\xED\xE8\xE9 \xF1\xF2\xE2\xEE\xF0\xE8\xF2\xE8\xF1\xFC EXE \xF4\xE0\xE9\xEB. \xC2\xF1\xB3 \xB3\xED\xF8\xB3 \xEE\xEF\xF6\xB3\xBF \xE2\xE8 \xEF\xEE\xE2\xE8\xED\xED\xB3 \xE2\xF1\xF2\xE0\xED\xEE\xE2\xE8\xF2\xE8 \xF1\xE0\xEC\xEE\xF1\xF2\xB3\xE9\xED\xEE (\xED\xE0\xEF\xF0\xE8\xEA\xEB\xE0\xE4 \xE7\xE0 \xE4\xEE\xEF\xEE\xEC\xEE\xE3\xEE\xFE *.bat \xF4\xE0\xE9\xEB\xF3). 4. TestLibrary \xCE\xC1\xCE\xC2'\xDF\xC7\xCA\xCE\xC2\xCE \xEF\xEE\xE2\xE8\xED\xED\xE0 \xE5\xEA\xF1\xEF\xEE\xF0\xF2\xF3\xE2\xE0\xF2\xE8 \xF2\xE0\xEA\xB3 \xF4\xF3\xED\xEA\xF6\xB3\xBF (\xB3\xED\xE0\xEA\xF8\xE5 \xF2\xE5\xF1\xF2\xF3\xE2\xE0\xEB\xEA\xE0 \xEF\xF0\xEE\xF1\xF2\xEE \xE2\xEF\xE0\xE4\xE5): - bool CheckCL(char* src, int cl, char* details) - bool CheckDF(char* src, int lang, char* details) - bool CheckRTL(int usedrealtime, int realtimelimit) - bool CheckTL(int usedtime, int timelimit) - int CheckAnswer(char* input, char* output, char* rightoutput) - void FreeChar(char* buf); - \xE4\xE5\xF2\xE0\xEB\xB3 \xF0\xE5\xE0\xEB\xB3\xE7\xE0\xF6\xB3\xBF \xF6\xE8\xF5 \xF4\xF3\xED\xEA\xF6\xB3\xE9 \xE2 SourceTest.h + bool CheckCL(char* src, int cl, char*& details) - must check codelimit + bool CheckDF(char* src, int lang, char*& details) - must check DF + bool CheckRTL(int usedrealtime, int realtimelimit) - must check RTL + bool CheckTL(int usedtime, int timelimit) - must check TL + int CheckAnswer(char* input, char* output, char* rightoutput, char*& Details) - checks WA,OE,PE + void FreeChar(char* buf); - must free memory used by buf + \xE4\xE5\xF2\xE0\xEB\xB3 \xF0\xE5\xE0\xEB\xB3\xE7\xE0\xF6\xB3\xBF \xF6\xE8\xF5 \xF4\xF3\xED\xEA\xF6\xB3\xE9 \xE2 SourceTest.h //////////////////////////////////////////////////////////////////////// ///////////////////////\xD1\xD2\xD0\xD3\xCA\xD2\xD3\xD0\xC0 \xD4\xC0\xC9˲\xC2///////////////////////////////// //////////////////////////////////////////////////////////////////////// Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp 2008-06-07 14:14:12 UTC (rev 226) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp 2008-06-07 19:51:51 UTC (rev 227) @@ -292,7 +292,7 @@ } } -TCheckAnsRes TSource::CheckAnswer(int index,String^ output) //checks answer for test +TCheckAnsRes TSource::CheckAnswer(int index,String^ output, String^% Details) //checks answer for test { try { @@ -306,10 +306,12 @@ return carAC; } else { - char* buf1,*buf2,*buf3; + char* buf1,*buf2,*buf3,*buf4=NULL; TCheckAnswer prc=(TCheckAnswer)GetProcAddress(lib,"CheckAnswer"); - TCheckAnsRes res=(TCheckAnsRes)prc(buf1=StrToArr(t.input),buf2=StrToArr(output),buf3=StrToArr(t.output)); - FreeArr(buf1);FreeArr(buf2);FreeArr(buf3); + TCheckAnsRes res=(TCheckAnsRes)prc(buf1=StrToArr(t.input),buf2=StrToArr(output),buf3=StrToArr(t.output),buf4); + Details+=gcnew String(buf4); + TFreeFunc prc2=(TFreeFunc)GetProcAddress(lib,"FreeChar"); + FreeArr(buf1);FreeArr(buf2);FreeArr(buf3);prc2(buf4); return res; } }__finally @@ -621,7 +623,7 @@ ReadFile(ouf,buf,size,&len,NULL); CloseHandle(ouf); - TCheckAnsRes r=CheckAnswer(index,gcnew String(buf)); + TCheckAnsRes r=CheckAnswer(index,gcnew String(buf),it->Details); delete[] buf; if (r==carAC) { Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.h =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.h 2008-06-07 14:14:12 UTC (rev 226) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.h 2008-06-07 19:51:51 UTC (rev 227) @@ -236,7 +236,7 @@ typedef bool (*TCheckSrc)(char* src,int,char*& details); typedef bool (*TCheckLim)(int,int); - typedef int (*TCheckAnswer)(char* input, char* output, char* rightoutput); + typedef int (*TCheckAnswer)(char* input, char* output, char* rightoutput, char*& Details); typedef void (*TFreeFunc)(char* buf); public delegate void TTestHandler(int index, TResult^ res); @@ -275,11 +275,11 @@ TLang FLang; //language of source TSecure *FSecurity; //security class HMODULE lib; //library that must export: - //bool CheckCL(char* src, int cl, char* details) - must check codelimit - //bool CheckDF(char* src, int lang, char* details) - must check DF + //bool CheckCL(char* src, int cl, char*& details) - must check codelimit + //bool CheckDF(char* src, int lang, char*& details) - must check DF //bool CheckRTL(int usedrealtime, int realtimelimit) - must check RTL //bool CheckTL(int usedtime, int timelimit) - must check TL - //int CheckAnswer(char* input, char* output, char* rightoutput) - checks WA,OE,PE + //int CheckAnswer(char* input, char* output, char* rightoutput, char*& Details) - checks WA,OE,PE //void FreeChar(char* buf); - must free memory used by buf //if there is no library called TestLibrary.dll then standart check is performed @@ -313,7 +313,7 @@ void Compile(); void RunTests(); //all tests void RunTest(int index); //only one test - TCheckAnsRes CheckAnswer(int index,String^ output); + TCheckAnsRes CheckAnswer(int index,String^ output, String^% Details); void ProcessAll(); //gets result for all tests void ProcessTest(int index); //gets result for only 1 test void LoadTest(int index,TTest% test); //load test from file Modified: ACMServer/branches/sharp tester/TestLibrary/TestLibrary.cpp =================================================================== --- ACMServer/branches/sharp tester/TestLibrary/TestLibrary.cpp 2008-06-07 14:14:12 UTC (rev 226) +++ ACMServer/branches/sharp tester/TestLibrary/TestLibrary.cpp 2008-06-07 19:51:51 UTC (rev 227) @@ -33,8 +33,10 @@ return (usedtime*1.0>(timelimit*TLk+TLx)); } -TESTLIBRARY_API int CheckAnswer(char* input, char* output, char* rightoutput) +TESTLIBRARY_API int CheckAnswer(char* input, char* output, char* rightoutput, char*& Details) { + Details=new char[30]; + strcpy(Details,"CheckAnswer from DLL\n"); if (strcmp(output,rightoutput)==0) return 0; int curo=0; Modified: ACMServer/branches/sharp tester/TestLibrary/TestLibrary.h =================================================================== --- ACMServer/branches/sharp tester/TestLibrary/TestLibrary.h 2008-06-07 14:14:12 UTC (rev 226) +++ ACMServer/branches/sharp tester/TestLibrary/TestLibrary.h 2008-06-07 19:51:51 UTC (rev 227) @@ -12,5 +12,5 @@ TESTLIBRARY_API void FreeChar(char* buf); TESTLIBRARY_API bool CheckRTL(int usedrealtime, int realtimelimit); TESTLIBRARY_API bool CheckTL(int usedtime, int timelimit); -TESTLIBRARY_API int CheckAnswer(char* input, char* output, char* rightoutput); +TESTLIBRARY_API int CheckAnswer(char* input, char* output, char* rightoutput, char*& Details); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-06-08 16:05:00
|
Revision: 228 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=228&view=rev Author: Oracle_ Date: 2008-06-08 09:05:03 -0700 (Sun, 08 Jun 2008) Log Message: ----------- Fixed bug with Temp path. Modified Paths: -------------- ACMServer/branches/sharp tester/ReadMe.txt ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp ACMServer/branches/sharp tester/SourceTest/SourceTest.h Modified: ACMServer/branches/sharp tester/ReadMe.txt =================================================================== --- ACMServer/branches/sharp tester/ReadMe.txt 2008-06-07 19:51:51 UTC (rev 227) +++ ACMServer/branches/sharp tester/ReadMe.txt 2008-06-08 16:05:03 UTC (rev 228) @@ -26,13 +26,14 @@ \xF6\xE5 \xF8\xEB\xFF\xF5 \xE4\xEE \xF1\xEE\xF0\xF1\xE0, \xE0 \xE4\xF0\xF3\xE3\xE8\xE9 - \xF6\xE5 \xF8\xEB\xFF\xF5, \xE4\xE5 \xEF\xEE\xE2\xE8\xED\xED\xE8\xE9 \xF1\xF2\xE2\xEE\xF0\xE8\xF2\xE8\xF1\xFC EXE \xF4\xE0\xE9\xEB. \xC2\xF1\xB3 \xB3\xED\xF8\xB3 \xEE\xEF\xF6\xB3\xBF \xE2\xE8 \xEF\xEE\xE2\xE8\xED\xED\xB3 \xE2\xF1\xF2\xE0\xED\xEE\xE2\xE8\xF2\xE8 \xF1\xE0\xEC\xEE\xF1\xF2\xB3\xE9\xED\xEE (\xED\xE0\xEF\xF0\xE8\xEA\xEB\xE0\xE4 \xE7\xE0 \xE4\xEE\xEF\xEE\xEC\xEE\xE3\xEE\xFE *.bat \xF4\xE0\xE9\xEB\xF3). 4. TestLibrary \xCE\xC1\xCE\xC2'\xDF\xC7\xCA\xCE\xC2\xCE \xEF\xEE\xE2\xE8\xED\xED\xE0 \xE5\xEA\xF1\xEF\xEE\xF0\xF2\xF3\xE2\xE0\xF2\xE8 \xF2\xE0\xEA\xB3 \xF4\xF3\xED\xEA\xF6\xB3\xBF (\xB3\xED\xE0\xEA\xF8\xE5 \xF2\xE5\xF1\xF2\xF3\xE2\xE0\xEB\xEA\xE0 \xEF\xF0\xEE\xF1\xF2\xEE \xE2\xEF\xE0\xE4\xE5): - bool CheckCL(char* src, int cl, char*& details) - must check codelimit - bool CheckDF(char* src, int lang, char*& details) - must check DF - bool CheckRTL(int usedrealtime, int realtimelimit) - must check RTL - bool CheckTL(int usedtime, int timelimit) - must check TL - int CheckAnswer(char* input, char* output, char* rightoutput, char*& Details) - checks WA,OE,PE - void FreeChar(char* buf); - must free memory used by buf - \xE4\xE5\xF2\xE0\xEB\xB3 \xF0\xE5\xE0\xEB\xB3\xE7\xE0\xF6\xB3\xBF \xF6\xE8\xF5 \xF4\xF3\xED\xEA\xF6\xB3\xE9 \xE2 SourceTest.h + bool CheckCL(char* src, int cl, char*& details) - must check codelimit + bool CheckDF(char* src, int lang, char*& details) - must check DF + bool CheckRTL(int usedrealtime, int realtimelimit) - must check RTL + bool CheckTL(int usedtime, int timelimit) - must check TL + int CheckAnswer(char* input, char* output, char* rightoutput, char*& Details) - checks WA,OE,PE + void FreeChar(char* buf); - must free memory used by buf + \xC1\xB3\xE1\xEB\xB3\xEE\xF2\xE5\xEA\xE0 \xEF\xEE\xE2\xE8\xED\xED\xE0 \xF1\xE0\xEC\xE0 \xE2\xE8\xE4\xB3\xEB\xFF\xF2\xE8 \xEF\xE0\xEC'\xFF\xF2\xFC \xEF\xB3\xE4 details, \xE0 \xE2\xE8\xE4\xE0\xEB\xFF\xF2\xE8 \xE1\xF3\xE4\xE5 \xF1\xE0\xEC\xE0 \xF2\xE5\xF1\xF2\xF3\xE2\xE0\xEB\xEA\xE0. + \xC4\xE5\xF2\xE0\xEB\xB3 \xF0\xE5\xE0\xEB\xB3\xE7\xE0\xF6\xB3\xBF \xF6\xE8\xF5 \xF4\xF3\xED\xEA\xF6\xB3\xE9 \xE2 SourceTest.h. //////////////////////////////////////////////////////////////////////// ///////////////////////\xD1\xD2\xD0\xD3\xCA\xD2\xD3\xD0\xC0 \xD4\xC0\xC9˲\xC2///////////////////////////////// //////////////////////////////////////////////////////////////////////// @@ -41,7 +42,7 @@ 2. InData.txt - \xEC\xB3\xF1\xF2\xE8\xF2\xFC 4 \xF0\xFF\xE4\xEA\xE8: \xE2 \xEF\xE5\xF0\xF8\xEE\xEC\xF3 - \xF8\xEB\xFF\xF5 \xE4\xEE \xEA\xEE\xEC\xEF\xB3\xEB\xFF\xF2\xEE\xF0\xE0 \xE2 \xE4\xF0\xF3\xE3\xEE\xEC\xF3 - \xF8\xEB\xFF\xF5 \xE4\xEE \xF2\xE5\xF1\xF2\xF3 - \xE2 \xF2\xF0\xE5\xF2\xFC\xEE\xEC\xF3 - \xF8\xEB\xFF\xF5 \xE4\xEE \xEF\xE0\xEF\xEA\xE8 \xE2 \xFF\xEA\xB3\xE9 \xE1\xF3\xE4\xF3\xF2\xFC \xE7\xE1\xE5\xF0\xB3\xE3\xE0\xF2\xE8\xF1\xFC \xEF\xF0\xEE\xEC\xB3\xE6\xED\xB3 \xF4\xE0\xE9\xEB\xE8 (\xEE\xE1\xEE\xE2'\xFF\xE7\xEA\xEE\xE2\xEE \xEF\xEE\xE2\xED\xE8\xE9, \xE0 \xED\xE5 \xE2\xB3\xE4\xED\xEE\xF1\xED\xE8\xE9) + \xE2 \xF2\xF0\xE5\xF2\xFC\xEE\xEC\xF3 - \xF8\xEB\xFF\xF5 \xE4\xEE \xEF\xE0\xEF\xEA\xE8 \xE2 \xFF\xEA\xB3\xE9 \xE1\xF3\xE4\xF3\xF2\xFC \xE7\xE1\xE5\xF0\xB3\xE3\xE0\xF2\xE8\xF1\xFC \xEF\xF0\xEE\xEC\xB3\xE6\xED\xB3 \xF4\xE0\xE9\xEB\xE8 \xE2 \xF7\xE5\xF2\xE2\xE5\xF0\xF2\xEE\xEC\xF3 - \xF8\xEB\xFF\xF5 \xE4\xEE \xF4\xE0\xE9\xEB\xF3, \xF9\xEE \xEC\xB3\xF1\xF2\xE8\xF2\xFC \xEA\xEE\xE4 \xEF\xF0\xEE\xE3\xF0\xE0\xEC\xE8 3. \xCA\xEE\xE6\xE5\xED \xF2\xE5\xF1\xF2 - \xF6\xE5 \xEF\xE0\xEF\xEA\xE0, \xF9\xEE \xEC\xB3\xF1\xF2\xE8\xF2\xFC \xF4\xE0\xE9\xEB Limits.txt \xB3 \xEF\xB3\xE4\xEF\xE0\xEF\xEA\xE8 \xE7 \xED\xE0\xE7\xE2\xE0\xEC\xE8 test1,test2, ... \xCA\xEE\xE6\xED\xE0 \xE7 \xF6\xE8\xF5 \xEF\xE0\xEF\xEE\xEA \xEC\xB3\xF1\xF2\xE8\xF2\xFC \xF4\xE0\xE9\xEB\xE8 in.txt,out.txt,points.txt. @@ -78,6 +79,7 @@ \xF2\xEE \xE7\xED\xE0\xF7\xE8\xF2\xFC \xE2 \xF1\xEE\xF0\xF1\xB3 \xE2\xE8\xE4\xB3\xEB\xFF\xBA\xF2\xFC\xF1\xFF \xE4\xF3\xE6\xE5 \xE2\xE5\xEB\xE8\xEA\xE8\xE9 \xEC\xE0\xF1\xE8\xE2. \xCF\xF0\xE8 \xF1\xF2\xE2\xEE\xF0\xE5\xED\xED\xB3 TSource \xEF\xF0\xEE\xE1\xF3\xBA \xE7\xED\xE0\xE9\xF2\xE8 \xFE\xE7\xE5\xF0\xE0 \xE7 \xB3\xEC'\xFF\xEC TestingUser, \xFF\xEA\xF9\xEE \xF2\xE0\xEA\xE8\xE9 \xED\xE5 \xB3\xF1\xED\xF3\xBA, \xF2\xEE \xF1\xF2\xE2\xEE\xF0\xFE\xBA \xE9\xEE\xE3\xEE \xB3 \xE7\xE0\xE1\xEE\xF0\xEE\xED\xFF\xBA \xE9\xEE\xEC\xF3 \xE4\xEE\xF1\xF2\xF3\xEF \xE4\xEE \xEB\xEE\xEA\xE0\xEB\xFC\xED\xE8\xF5 \xE4\xE8\xF1\xEA\xB3\xE2. \xD6\xE5 \xEC\xEE\xE6\xE5 \xE7\xE0\xE9\xED\xFF\xF2\xE8 \xEA\xB3\xEB\xFC\xEA\xE0 \xF5\xE2\xE8\xEB\xE8\xED. +\xC2 \xFE\xE7\xE5\xF0\xE0 TestingUser \xEF\xE0\xF0\xEE\xEB\xFC USER12345. \xDF\xEA\xF9\xEE \xEF\xF0\xEE\xE3\xF0\xE0\xEC\xB3 \xED\xE5 \xE2\xE4\xE0\xBA\xF2\xFC\xF1\xFF \xF1\xF2\xE2\xEE\xF0\xE8\xF2\xE8 \xEF\xF0\xEE\xF6\xE5\xF1 \xE2\xB3\xE4 \xB3\xEC\xE5\xED\xB3 TestingUSer, \xF2\xEE \xE2\xEE\xED\xE0 \xE9\xEE\xE3\xEE \xF1\xF2\xE2\xEE\xF0\xFE\xBA \xE2\xB3\xE4 \xB3\xEC\xE5\xED\xB3 \xFE\xE7\xE5\xF0\xE0 \xEF\xB3\xE4 \xFF\xEA\xE8\xEC \xE7\xE0\xEF\xF3\xF1\xEA\xE0\xBA\xF2\xFC\xF1\xFF \xF1\xE0\xEC\xE0. \xD2\xEE\xE4\xB3 \xEF\xF0\xEE\xF6\xE5\xF1 \xF1\xF2\xE0\xBA Unsecured \xB3 \xEC\xEE\xE6\xE5 \xE4\xEE\xF1\xF2\xF3\xEF\xE0\xF2\xE8\xF1\xFC \xE4\xEE \xF4\xE0\xE9\xEB\xEE\xE2\xEE\xBF \xF1\xE8\xF1\xF2\xE5\xEC\xE8. \ No newline at end of file Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp 2008-06-07 19:51:51 UTC (rev 227) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp 2008-06-08 16:05:03 UTC (rev 228) @@ -63,10 +63,18 @@ FCompPath=gcnew String(""); FRunAll=true; lib=LoadLibraryA("TestLibrary.dll"); -FSecurity=new TSecure(); +FSecurity=NULL; +InitSecure(false); init(); //initializing of critical section } +void TSource::InitSecure(bool SetPrivAnyway) +{ + if (FSecurity!=NULL) + delete FSecurity; + FSecurity=new TSecure(SetPrivAnyway); +} + TSource::~TSource() { if (lib!=NULL) @@ -777,7 +785,7 @@ fi->SetAccessControl(fs); } -TSecure::TSecure() +TSecure::TSecure(bool SetPrivAnyway) //if SetPrivAnyway==true, then all destrictions are set to the user even if it already exists { SetUserObjectFullAccess( GetThreadDesktop(GetCurrentThreadId())); //needed for accessing from CreateProcessAsUser SetUserObjectFullAccess( GetProcessWindowStation()); //needed for accessing from CreateProcessAsUser @@ -792,29 +800,35 @@ ui.usri1_priv=USER_PRIV_USER; ui.usri1_script_path=NULL; st=NetUserAdd(NULL,1,(LPBYTE)&ui,NULL); //trying to create new user + bool userex=false; if (st!=NERR_Success) { if (st==NERR_UserExists) - return; //if user exists just do nothing - MessageBox(NULL,L"Can not create testing user - only unsecured mode",L"Warning",MB_ICONWARNING|MB_OK); - return; + userex=true; else + { + MessageBox(NULL,L"Can not create testing user - only unsecured mode",L"Warning",MB_ICONWARNING|MB_OK); + return; + } } - array<DriveInfo^>^ drv=DriveInfo::GetDrives(); - for (int i=0;i<drv->Length;i++) //for all drives set limitation - if (drv[i]->DriveType==DriveType::Fixed) - DenyAccessFolder(drv[i]->Name); - wchar_t buf[MAX_PATH+1]; - GetEnvironmentVariableW(L"ProgramFiles",buf,MAX_PATH); - DenyAccessFolder(gcnew String(buf)); - GetEnvironmentVariable(L"ALLUSERSPROFILE",buf,MAX_PATH); - DenyAccessFolder(gcnew String(buf)); - GetWindowsDirectory(buf,MAX_PATH); - DenyAccessFolder(gcnew String(buf)); - GetSystemDirectory(buf,MAX_PATH); - DenyAccessFolder(gcnew String(buf)); - DWORD size=MAX_PATH; - GetProfilesDirectory(buf,&size); - DenyAccessFolder(gcnew String(buf)); + if ((!userex)||(SetPrivAnyway)) + { + array<DriveInfo^>^ drv=DriveInfo::GetDrives(); + for (int i=0;i<drv->Length;i++) //for all drives set limitation + if (drv[i]->DriveType==DriveType::Fixed) + DenyAccessFolder(drv[i]->Name); + wchar_t buf[MAX_PATH+1]; + GetEnvironmentVariableW(L"ProgramFiles",buf,MAX_PATH); + DenyAccessFolder(gcnew String(buf)); + GetEnvironmentVariable(L"ALLUSERSPROFILE",buf,MAX_PATH); + DenyAccessFolder(gcnew String(buf)); + GetWindowsDirectory(buf,MAX_PATH); + DenyAccessFolder(gcnew String(buf)); + GetSystemDirectory(buf,MAX_PATH); + DenyAccessFolder(gcnew String(buf)); + DWORD size=MAX_PATH; + GetProfilesDirectory(buf,&size); + DenyAccessFolder(gcnew String(buf)); + } } TSecure::~TSecure() @@ -826,6 +840,9 @@ { HANDLE token=NULL,Token=NULL; wchar_t* env=NULL; + wchar_t buflpCommandLine[MAX_PATH+1]; + if (!GetFullPathName(lpCommandLine,MAX_PATH,buflpCommandLine,NULL)) + wcscpy(buflpCommandLine,lpCommandLine); if (LogonUser((LPWSTR)USER_NAME,(LPWSTR)".",(LPWSTR)USER_PASSW,LOGON32_LOGON_NETWORK,LOGON32_PROVIDER_DEFAULT,&Token)) { FileInfo^ fi=gcnew FileInfo(gcnew String(lpCommandLine)); @@ -838,7 +855,7 @@ { if (CreateEnvironmentBlock((LPVOID*)&env,token,FALSE)) { - if (CreateProcessAsUser(token,NULL,lpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags|CREATE_UNICODE_ENVIRONMENT,env,NULL,lpStartupInfo,lpProcessInformation)) + if (CreateProcessAsUser(token,NULL,buflpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags|CREATE_UNICODE_ENVIRONMENT,env,NULL,lpStartupInfo,lpProcessInformation)) { DestroyEnvironmentBlock(env); RevertToSelf(); @@ -858,7 +875,7 @@ if (Token!=NULL) CloseHandle(Token); Details="Unsecured process. Result details: "; - if (CreateProcess(NULL,lpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags,NULL,NULL,lpStartupInfo,lpProcessInformation)) + if (CreateProcess(NULL,buflpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags,NULL,NULL,lpStartupInfo,lpProcessInformation)) return true; return false; } Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.h =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.h 2008-06-07 19:51:51 UTC (rev 227) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.h 2008-06-08 16:05:03 UTC (rev 228) @@ -249,7 +249,7 @@ { private: public: - TSecure(); + TSecure(bool SetPrivAnyway); ~TSecure(); bool RunProcess(LPWSTR lpCommandLine,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo,LPPROCESS_INFORMATION lpProcessInformation,String^% Details); }; @@ -308,6 +308,7 @@ public: TSource(); ~TSource(); + void InitSecure(bool SetPrivAnyway); void CheckCL(); void CheckDF(); void Compile(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |