From: <Or...@us...> - 2008-06-17 15:38:16
|
Revision: 262 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=262&view=rev Author: Oracle_ Date: 2008-06-17 08:36:50 -0700 (Tue, 17 Jun 2008) Log Message: ----------- Fixed bug with RealTime limit. Modified Paths: -------------- ACMServer/trunk/sharp tester/ReadMe.txt ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp Modified: ACMServer/trunk/sharp tester/ReadMe.txt =================================================================== --- ACMServer/trunk/sharp tester/ReadMe.txt 2008-06-17 09:02:14 UTC (rev 261) +++ ACMServer/trunk/sharp tester/ReadMe.txt 2008-06-17 15:36:50 UTC (rev 262) @@ -12,7 +12,9 @@ 3. \xD3 \xEF\xE0\xEF\xEA\xF3 SAMPLE \xE4\xEE\xE4\xE0\xF2\xE8 \xEA\xEE\xEC\xEF\xB3\xEB\xFF\xF2\xEE\xF0 Delphi, \xE0 \xF3 \xEF\xE0\xEF\xEA\xF3 includeD7 \xE4\xEE\xE4\xE0\xF2\xE8 \xED\xE5\xEE\xE1\xF5\xB3\xE4\xED\xB3 \xE4\xEB\xFF \xF0\xEE\xE1\xEE\xF2\xE8 \xEC\xEE\xE4\xF3\xEB\xB3. 4. \xC4\xEB\xFF \xEA\xEE\xEC\xEF\xB3\xEB\xFF\xF6\xB3\xBF \xEF\xEE\xF2\xF0\xB3\xE1\xE5\xED .NET Framework 2.0 \xE0\xE1\xEE \xE2\xE8\xF9\xE5. -5. ϳ\xF1\xEB\xFF \xEA\xEE\xEC\xEF\xB3\xEB\xFF\xF6\xB3\xBF \xEF\xEE\xEC\xB3\xF1\xF2\xB3\xF2\xFC \xE4\xEE \xF4\xE0\xE9\xEB\xF3 tester.exe \xF4\xE0\xE9\xEB TestLibrary.dll i +5. \xC4\xEB\xFF \xEA\xEE\xEC\xEF\xB3\xEB\xFF\xF6\xB3\xBF TestLibrary \xEF\xEE\xF2\xF0\xB3\xE1\xED\xEE \xE4\xEE \xEF\xF0\xEE\xE5\xEA\xF2\xF3 \xE4\xEE\xE4\xE0\xF2\xE8 *.def \xF4\xE0\xE9\xEB \xB3 + \xE2\xE2\xE5\xF1\xF2\xE8 \xE9\xEE\xE3\xEE \xE2 \xEE\xEF\xF6\xB3\xFF\xF5 \xEF\xF0\xEE\xE5\xEA\xF2\xF3. +6. ϳ\xF1\xEB\xFF \xEA\xEE\xEC\xEF\xB3\xEB\xFF\xF6\xB3\xBF \xEF\xEE\xEC\xB3\xF1\xF2\xB3\xF2\xFC \xE4\xEE \xF4\xE0\xE9\xEB\xF3 tester.exe \xF4\xE0\xE9\xEB TestLibrary.dll i SourceTest.dll //////////////////////////////////////////////////////////////////////// ///////////////////////\xC7\xC0\xCF\xD3\xD1\xCA \xB2 \xC2\xC8\xCA\xCE\xCD\xC0\xCD\xCD\xDF/////////////////////////////// Modified: ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp =================================================================== --- ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp 2008-06-17 09:02:14 UTC (rev 261) +++ ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp 2008-06-17 15:36:50 UTC (rev 262) @@ -1,7 +1,6 @@ // This is the main DLL file. #include "stdafx.h" -//#define _WIN32_WINNT 0x0500 #include <stdio.h> #include "SourceTest.h" #include <LM.h> @@ -349,23 +348,6 @@ } } -BOOL DelPrivilege(HANDLE hToken,LPCTSTR lpszPrivilege) //deletes privilege from process token -{ -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_REMOVED; - -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; -} - BOOL AddPrivilege(HANDLE hToken,LPCTSTR lpszPrivilege) //adds privilege to process token { TOKEN_PRIVILEGES tp; @@ -383,53 +365,6 @@ return TRUE; } -void DeletePrivileges(HANDLE proc) //deletes all privileges from process token -{ - HANDLE hToken; - try - { - OpenProcessToken(proc,TOKEN_ALL_ACCESS,&hToken); - DelPrivilege(hToken,SE_ASSIGNPRIMARYTOKEN_NAME); - DelPrivilege(hToken,SE_AUDIT_NAME); - DelPrivilege(hToken,SE_BACKUP_NAME); - DelPrivilege(hToken,SE_CHANGE_NOTIFY_NAME); - DelPrivilege(hToken,SE_CREATE_GLOBAL_NAME); - DelPrivilege(hToken,SE_CREATE_PAGEFILE_NAME); - DelPrivilege(hToken,SE_CREATE_PERMANENT_NAME); - DelPrivilege(hToken,SE_CREATE_SYMBOLIC_LINK_NAME); - DelPrivilege(hToken,SE_CREATE_TOKEN_NAME); - DelPrivilege(hToken,SE_DEBUG_NAME); - DelPrivilege(hToken,SE_ENABLE_DELEGATION_NAME); - DelPrivilege(hToken,SE_IMPERSONATE_NAME); - DelPrivilege(hToken,SE_INC_BASE_PRIORITY_NAME); - DelPrivilege(hToken,SE_INCREASE_QUOTA_NAME); - DelPrivilege(hToken,SE_INC_WORKING_SET_NAME); - DelPrivilege(hToken,SE_LOAD_DRIVER_NAME); - DelPrivilege(hToken,SE_LOCK_MEMORY_NAME); - DelPrivilege(hToken,SE_MACHINE_ACCOUNT_NAME); - DelPrivilege(hToken,SE_MANAGE_VOLUME_NAME); - DelPrivilege(hToken,SE_PROF_SINGLE_PROCESS_NAME); - DelPrivilege(hToken,SE_RELABEL_NAME); - DelPrivilege(hToken,SE_REMOTE_SHUTDOWN_NAME); - DelPrivilege(hToken,SE_RESTORE_NAME); - DelPrivilege(hToken,SE_SECURITY_NAME); - DelPrivilege(hToken,SE_SHUTDOWN_NAME); - DelPrivilege(hToken,SE_SYNC_AGENT_NAME); - DelPrivilege(hToken,SE_SYSTEM_ENVIRONMENT_NAME); - DelPrivilege(hToken,SE_SYSTEM_PROFILE_NAME); - DelPrivilege(hToken,SE_SYSTEMTIME_NAME); - DelPrivilege(hToken,SE_TAKE_OWNERSHIP_NAME); - DelPrivilege(hToken,SE_TCB_NAME); - DelPrivilege(hToken,SE_TIME_ZONE_NAME); - DelPrivilege(hToken,SE_TRUSTED_CREDMAN_ACCESS_NAME); - DelPrivilege(hToken,SE_UNDOCK_NAME); - DelPrivilege(hToken,SE_UNSOLICITED_INPUT_NAME); - }__finally - { - CloseHandle(hToken); - } -} - void TSource::RunTest(int index) //runs one test { PROCESS_INFORMATION pi;ZeroMemory(&pi,sizeof(pi)); @@ -496,20 +431,17 @@ mem.BasicLimitInformation.LimitFlags=JOB_OBJECT_LIMIT_PROCESS_MEMORY; mem.ProcessMemoryLimit=FLim.MemoryLimit; SetInformationJobObject(job,JobObjectExtendedLimitInformation,&mem,sizeof(mem)); - port.CompletionKey=(void*)123; port.CompletionPort=CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0); - SetInformationJobObject(job,JobObjectAssociateCompletionPortInformation,&port,sizeof(port)); uilim.UIRestrictionsClass=JOB_OBJECT_UILIMIT_ALL; SetInformationJobObject(job,JobObjectBasicUIRestrictions,&uilim,sizeof(uilim)); - - DeletePrivileges(pi.hProcess); + AssignProcessToJobObject(job,pi.hProcess); + ResumeThread(pi.hThread); DWORD start=GetTickCount(); - while (true) { if ((int)GetFileSize(si.hStdOutput,NULL)>FLim.OutputLimit) @@ -558,10 +490,11 @@ unsigned long len,key; HANDLE proc; - if (GetQueuedCompletionStatus(port.CompletionPort, &len, &key, (LPOVERLAPPED*)&proc, 1)&&key == 123) + if (GetQueuedCompletionStatus(port.CompletionPort, &len, &key, (LPOVERLAPPED*)&proc, 1)) { DWORD code=0; bool needbreak=false; + if (key==123) switch(len) { case JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS: @@ -604,7 +537,6 @@ break; } } - Sleep(1); } CloseHandle(si.hStdOutput); @@ -664,13 +596,13 @@ }__finally { - CloseHandle(job); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); CloseHandle(si.hStdInput); CloseHandle(si.hStdOutput); CloseHandle(si.hStdError); CloseHandle(port.CompletionPort); + CloseHandle(job); FState=ssTestComplete; if (FTestHandler) FTestHandler(index,(TResult^)FRes[index-1]); @@ -863,6 +795,7 @@ { if (CreateEnvironmentBlock((LPVOID*)&env,token,FALSE)) { + //DeletePrivileges(token); if (CreateProcessAsUser(token,NULL,buflpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags|CREATE_UNICODE_ENVIRONMENT,env,NULL,lpStartupInfo,lpProcessInformation)) { DestroyEnvironmentBlock(env); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |