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. |