static SIZE_TYPE Pack (const SrcCont& src, TCoding src_coding, DstCont& dst, TCoding& dst_coding, TSeqPos length) { if ( src.empty() || (length == 0) ) { return 0; } AdjustLength(src, src_coding, 0, length); // we allocate enough memory for ncbi4na coding // if the result will be ncbi2na coding we'll resize (see below) ResizeDst(dst, CSeqUtil::e_Ncbi4na, length); SIZE_TYPE res = Pack(&*src.begin(), length, src_coding, &*dst.begin(), dst_coding); if ( dst_coding == CSeqUtil::e_Ncbi2na ) { size_t new_size = res / 4; if ( (res % 4) != 0 ) { ++new_size; } dst.resize(new_size); } return res; }
static SIZE_TYPE Pack (const SrcCont& src, TCoding src_coding, IPackTarget& dst, TSeqPos length) { if ( src.empty() || (length == 0) ) { return 0; } AdjustLength(src, src_coding, 0, length); return Pack(&*src.begin(), length, src_coding, dst); }
void CNPC_Hydra::RunAI( void ) { CheckLength( ); AdjustLength( ); BaseClass::RunAI(); CalcGoalForces( ); MoveBody( ); int i; for (i = 1; i < CHAIN_LINKS && i < m_body.Count(); i++) { m_vecChain.Set( i, m_body[i].vecPos ); #if 0 if (m_body[i].bStuck) { NDebugOverlay::Box(m_body[i].vecPos, Vector( -2, -2, -2 ), Vector( 2, 2, 2 ), 255, 0, 0, 20, .1); } else { NDebugOverlay::Box(m_body[i].vecPos, Vector( -2, -2, -2 ), Vector( 2, 2, 2 ), 0, 255, 0, 20, .1); } NDebugOverlay::Line( m_body[i].vecPos, m_body[i].vecPos + m_body[i].vecDelta, 0, 255, 0, true, .1); NDebugOverlay::Line( m_body[i-1].vecPos, m_body[i].vecPos, 255, 255, 255, true, .1); #endif #if 0 char text[128]; Q_snprintf( text, sizeof( text ), "%d", i ); NDebugOverlay::Text( m_body[i].vecPos, text, false, 0.1 ); #endif #if 0 char text[128]; Q_snprintf( text, sizeof( text ), "%4.0f", (m_body[i].vecPos - m_body[i-1].vecPos).Length() * 100 / m_idealSegmentLength - 100); NDebugOverlay::Text( 0.5*(m_body[i-1].vecPos + m_body[i].vecPos), text, false, 0.1 ); #endif } //NDebugOverlay::Box(m_body[i].vecPos, Vector( -2, -2, -2 ), Vector( 2, 2, 2 ), 0, 255, 0, 20, .1); //NDebugOverlay::Box( m_vecHeadGoal, Vector( -2, -2, -2 ), Vector( 2, 2, 2 ), 255, 255, 0, 20, .1); for (; i < CHAIN_LINKS; i++) { m_vecChain.Set( i, m_vecChain[i-1] ); } }
static SIZE_TYPE Subseq (const SrcCont& src, TCoding coding, TSeqPos pos, TSeqPos length, DstCont& dst) { _ASSERT(!OutOfRange(pos, src, coding)); if ( src.empty() || (length == 0) ) { return 0; } AdjustLength(src, coding, pos, length); ResizeDst(dst, coding, length); return Subseq(&*src.begin(), coding, pos, length, &*dst.begin()); }
static SIZE_TYPE Convert (const SrcCont& src, TCoding src_coding, TSeqPos pos, TSeqPos length, DstCont& dst, TCoding dst_coding) { _ASSERT(!OutOfRange(pos, src, src_coding)); if ( src.empty() || (length == 0) ) { return 0; } AdjustLength(src, src_coding, pos, length); ResizeDst(dst, dst_coding, length); return Convert(&*src.begin(), src_coding, pos, length, &*dst.begin(), dst_coding); }
DWORD WINAPI LimitPlus( LPVOID lpVoid ) { int i, j; LPHACK_PARAMS lphp = (LPHACK_PARAMS) lpVoid; const HWND hWnd = lphp->myHwnd; const LPTARGETINFO lpTarget = lphp->lpTarget; EnableMenuItem( GetMenu( hWnd ), IDM_WATCH, MF_BYCOMMAND | MF_GRAYED ); EnableMenuItem( GetMenu( hWnd ), IDM_UNWATCH, MF_BYCOMMAND | MF_ENABLED ); g_dwTargetProcessId[ 2 ] = WATCHING_IDLE; UpdateStatus( hWnd ); TCHAR lpszTargetPath[ MAX_PATH * 2 ]; TCHAR lpszTargetExe[ MAX_PATH * 2 ]; lstrcpy( lpszTargetPath, lpTarget->szPath ); lstrcpy( lpszTargetExe, lpTarget->szExe ); wsprintf( g_szTarget[ 2 ], TEXT( "%s (Watching)" ), lpszTargetPath ); for( i = 8; i < 12; i++ ) { lstrcpy( lphp->lpszStatus[ i ], TEXT( "" ) ); } lstrcpy( lphp->lpszStatus[ 13 ], TEXT( "Watching..." ) ); TCHAR str[ MAX_PATH * 2 ]; #ifdef _UNICODE lstrcpy( lphp->lpszStatus[ 14 ], lpszTargetPath ); #else lstrcpy( str, lpszTargetPath ); if( lstrlen( str ) >= 19 ) { str[ 15 ] = '\0'; PathToExeEx( str, MAX_PATH * 2 ); } lstrcpy( lphp->lpszStatus[ 14 ], str ); #endif wsprintf( str, TEXT( "Watching : %s" ), lpszTargetPath ); WriteDebugLog( str ); AdjustLength( lphp->lpszStatus[ 14 ] ); g_Slider[ 2 ] = (BYTE) GetSliderIni( lpszTargetPath ); for( ; ; ) { if( lphp->lpTarget->dwProcessId == TARGET_PID_NOT_SET ) { g_dwTargetProcessId[ 2 ] = PathToProcess( lpszTargetPath ); } else { g_dwTargetProcessId[ 2 ] = lphp->lpTarget->dwProcessId; wsprintf( str, TEXT( "Watching : ProcessID given : %08lX" ), g_dwTargetProcessId[ 2 ] ); WriteDebugLog( str ); } if( g_dwTargetProcessId[ 2 ] == g_dwTargetProcessId[ 0 ] ) { if( g_bHack[ 0 ] ) { SendMessage( hWnd, WM_USER_STOP, 0U, 0L ); } Sleep( 500UL ); for( i = 0; i < 4; i++ ) { lstrcpy( lphp->lpszStatus[ i ], TEXT( "" ) ); } g_dwTargetProcessId[ 0 ] = TARGET_PID_NOT_SET; lstrcpy( g_szTarget[ 0 ], TARGET_UNDEF ); } else if( g_dwTargetProcessId[ 2 ] == g_dwTargetProcessId[ 1 ] ) { if( g_bHack[ 1 ] ) { SendMessage( hWnd, WM_USER_STOP, 1U, 0L ); } Sleep( 500UL ); for( i = 4; i < 8; i++ ) { lstrcpy( lphp->lpszStatus[ i ], TEXT( "" ) ); } g_dwTargetProcessId[ 1 ] = TARGET_PID_NOT_SET; lstrcpy( g_szTarget[ 1 ], TEXT( "<target not specified>" ) ); } if( g_dwTargetProcessId[ 2 ] == (DWORD) -1 ) { if( lstrcmp( lphp->lpszStatus[ 15 ], TEXT( "Not found" ) ) != 0 ) { wsprintf( lphp->lpszStatus[ 15 ], TEXT( "Not found" ) ); InvalidateRect( hWnd, NULL, TRUE ); } for( j = 0; j < 80; j++ ) // wait 8 seconds { Sleep( 100UL ); if( ! g_bHack[ 3 ] ) goto EXIT_THREAD; } } else { wsprintf( str, TEXT( "Watching : Found! <%s>" ), lpszTargetPath ); WriteDebugLog( str ); lphp->lpTarget->dwProcessId = g_dwTargetProcessId[ 2 ]; lstrcpy( lphp->lpTarget->szPath, lpszTargetPath ); lstrcpy( lphp->lpTarget->szExe , lpszTargetExe ); lstrcpy( lphp->lpTarget->szText, TEXT( "" ) ); g_Slider[ 2 ] = (BYTE) GetSliderIni( lpszTargetPath ); SendMessage( hWnd, WM_USER_HACK, (WPARAM) 2, (LPARAM) lphp ); UpdateStatus( hWnd ); wsprintf( lphp->lpszStatus[ 15 ], TEXT( "Found ( %08lX )" ), g_dwTargetProcessId[ 2 ] ); InvalidateRect( hWnd, NULL, TRUE ); while( g_dwTargetProcessId[ 2 ] != TARGET_PID_NOT_SET ) { Sleep( 100UL ); if( g_bHack[ 3 ] == FALSE ) { WriteDebugLog( TEXT( "g_bHack[ 3 ] == FALSE" ) ); goto EXIT_THREAD; } } if( WaitForSingleObject( hSemaphore[ 2 ], 1000UL ) != WAIT_OBJECT_0 ) { g_bHack[ 2 ] = FALSE; MessageBox( hWnd, TEXT("Sema Error in LimitPlus()"), APP_NAME, MB_OK | MB_ICONEXCLAMATION ); goto EXIT_THREAD; } g_dwTargetProcessId[ 2 ] = WATCHING_IDLE; UpdateStatus( hWnd ); } } EXIT_THREAD: WriteDebugLog( TEXT( "Watch: Exiting Thread..." ) ); // if the Watched is idle, we will free the slot #2 when 'unwatch' is posted // (Otherwise, #2 should be still active) if( g_dwTargetProcessId[ 2 ] == WATCHING_IDLE ) { g_dwTargetProcessId[ 2 ] = TARGET_PID_NOT_SET; lphp->lpTarget->dwProcessId = TARGET_PID_NOT_SET; g_bHack[ 2 ] = FALSE; ReleaseSemaphore( hSemaphore[ 2 ], 1L, (LONG *) NULL ); } if( ReleaseSemaphore( hSemaphore[ 3 ], 1L, (LONG *) NULL ) ) { WriteDebugLog( TEXT( "* Sema3 Released" ) ); } else { WriteDebugLog( TEXT( "[!] Sema3 Not released" ) ); } lstrcpy( lphp->lpszStatus[ 13 ], TEXT( "* Not watching *" ) ); lstrcpy( lphp->lpszStatus[ 14 ], lpszTargetPath ); AdjustLength( lphp->lpszStatus[ 14 ] ); lstrcpy( lphp->lpszStatus[ 15 ], TEXT( "" ) ); InvalidateRect( hWnd, NULL, TRUE ); if( ! g_bHack[ 2 ] ) { EnableMenuItem( GetMenu( hWnd ), IDM_WATCH, MF_BYCOMMAND | MF_ENABLED ); } EnableMenuItem( GetMenu( hWnd ), IDM_UNWATCH, MF_BYCOMMAND | MF_GRAYED ); UpdateStatus( hWnd ); g_bHack[ 3 ] = FALSE; // just in case return NOT_WATCHING; }
DWORD WINAPI Hack( LPVOID lpVoid ) { TCHAR msg[ 4096 ]; LPHACK_PARAMS lphp = (LPHACK_PARAMS) lpVoid; HWND hWnd = lphp -> myHwnd; const int iMyId = lphp -> iMyId; LPTARGETINFO lpTarget = lphp -> lpTarget; LPTSTR * lpszStatus = lphp -> lpszStatus; DWORD dwTargetProcessId = lpTarget -> dwProcessId; DWORD dwPrevSuspendCount; DWORD dwTotalChanges = 0; int iPrevThreadCount = 0; int errorflag = 0; const RECT minirect = { 20L, 20L + 90L * iMyId, 479L, 40L + 90L * iMyId }; const RECT hackrect = { 20L, 20L + 90L * iMyId, 479L, 100L + 90L * iMyId }; TCHAR lpszEnemyPath[ MAX_PATH * 2 ] = _T(""); TCHAR lpszEnemyExe[ MAX_PATH * 2 ] = _T(""); lstrcpy( lpszEnemyPath, lpTarget->szPath ); lstrcpy( lpszEnemyExe, lpTarget->szExe ); int i , j; HANDLE hProcess = NULL; DWORD dwOldPriority = NORMAL_PRIORITY_CLASS; int iOpenThreadRetry = 0; int iSuspendThreadRetry = 0; int iResumeThreadRetry = 0; SYSTEMTIME st; for( i = 0 + iMyId * 4; i < 4 + iMyId * 4; i++ ) { lstrcpy( lpszStatus[ i ], TEXT( "" ) ); } lstrcpy( lpszStatus[ 2 + iMyId * 4 ], lpszEnemyPath ); #if !defined( _UNICODE ) // for watching... if( iMyId == 2 && lstrlen( lpszEnemyPath ) >= 19 ) { lpszStatus[ 2 + iMyId * 4 ][ 15 ] = '\0'; PathToExeEx( lpszStatus[ 2 + iMyId * 4 ], MAX_PATH * 2 ); } #endif AdjustLength( lpszStatus[ 2 + iMyId * 4 ] ); for( DWORD dwOuterLoops = 0; g_bHack[ iMyId ]; dwOuterLoops++ ) { if( dwOuterLoops == 0UL ) { hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_SET_INFORMATION , FALSE, dwTargetProcessId ); if( hProcess ) { dwOldPriority = GetPriorityClass( hProcess ); wsprintf( msg, TEXT( "Target #%d: \"%s\"\r\n\tProcess ID = 0x%08lX : hProcess = 0x%08lX (Priority: %lu)" ), iMyId + 1, lpszEnemyPath, dwTargetProcessId, hProcess, dwOldPriority ); WriteDebugLog( msg ); if( g_bRealTime ) { WriteDebugLog( SetPriorityClass( hProcess, IDLE_PRIORITY_CLASS )? TEXT( "SetPriorityClass OK" ) : TEXT( "SetPriorityClass failed" ) ); } } else { WriteDebugLog( TEXT( "OpenProcess failed." ) ); GetLocalTime( &st ); wsprintf( lpszStatus[ 1 + iMyId * 4 ], TEXT( "Process ID = n/a" ) ); wsprintf( lpszStatus[ 3 + iMyId * 4 ], TEXT( "%02d:%02d:%02d Initial OpenThread failed" ), st.wHour, st.wMinute, st.wSecond ); g_dwTargetProcessId[ iMyId ] = TARGET_PID_NOT_SET; // This is needed as a workaround UpdateStatus( hWnd ); if( ReleaseSemaphore( hSemaphore[ iMyId ], 1L, (LPLONG) NULL ) ) { wsprintf( msg, TEXT( "* ReleaseSemaphore #%d in Hack()" ), iMyId + 1 ); WriteDebugLog( msg ); } else { wsprintf( msg, TEXT( "[!] Target #%d : ReleaseSemaphore failed in Hack(): ErrCode %lu" ), iMyId + 1, GetLastError() ); WriteDebugLog( msg ); } lphp->lpTarget->dwProcessId = TARGET_PID_NOT_SET; if( PathToProcess( lpszEnemyPath ) == ( DWORD ) -1 ) { SendMessageCallback( hWnd, WM_USER_STOP, (WPARAM) iMyId, (LPARAM) TARGET_MISSING, (SENDASYNCPROC) DummyCallback, (DWORD) hWnd ); InvalidateRect( hWnd, NULL, TRUE ); return TARGET_MISSING; } else { SendMessageCallback( hWnd, WM_USER_STOP, (WPARAM) iMyId, (LPARAM) THREAD_NOT_OPENED, (SENDASYNCPROC) DummyCallback, (DWORD) hWnd ); InvalidateRect( hWnd, NULL, TRUE ); return THREAD_NOT_OPENED; } } wsprintf( lpszStatus[ 0 + iMyId * 4 ], TEXT( "Target #%d [ -%d%% ]" ), iMyId + 1, g_Slider[ iMyId ] ); } // endif( dwOuterLoops == 0 ) DWORD dwThreadId[ MAX_THREAD_CNT ]; int iThreadCount = ListProcessThreads( dwTargetProcessId, dwThreadId ); // ----------------------- @@@ if( iThreadCount == 0 ) { GetLocalTime( &st ); wsprintf( lpszStatus[ 1 + iMyId * 4 ], TEXT( "Process ID = n/a" ) ); wsprintf( lpszStatus[ 3 + iMyId * 4 ], TEXT( "%02d:%02d:%02d No threads" ), st.wHour, st.wMinute, st.wSecond ); g_dwTargetProcessId[ iMyId ] = TARGET_PID_NOT_SET; if( hProcess ) { SetPriorityClass( hProcess, dwOldPriority ); CloseHandle( hProcess ); } if( ReleaseSemaphore( hSemaphore[ iMyId ], 1L, (LPLONG) NULL ) ) { wsprintf( msg, TEXT( "* TARGET_MISSING #%d : ReleaseSemaphore in Hack()" ), iMyId + 1 ); WriteDebugLog( msg ); } else { wsprintf( msg, TEXT( "[!] Target #%d : ReleaseSemaphore failed in Hack(): ErrCode %lu" ), iMyId + 1, GetLastError() ); WriteDebugLog( msg ); } g_bBlock = TRUE; WriteDebugLog( TEXT("SendMessage Doing...") ); SendMessageCallback( hWnd, WM_USER_STOP, (WPARAM) iMyId, (LPARAM) TARGET_MISSING, (SENDASYNCPROC) DummyCallback, (DWORD) hWnd ); WriteDebugLog( TEXT("SendMessage Done!") ); for( int z = 0; z < 10; z++ ) { if( ! g_bBlock ) { wsprintf( msg, TEXT("g_bBlock cleared at z=%d"), z ); WriteDebugLog( msg ); break; } Sleep( 10UL ); } lphp->lpTarget->dwProcessId = TARGET_PID_NOT_SET; // [email protected] beta // This is not needed because WM_USER_STOP will do the same, // and this thread will die (so thie order wil be probably void) anyway // InvalidateRect( hWnd, NULL, TRUE ); return TARGET_MISSING; } if( dwOuterLoops == 0UL ) { iPrevThreadCount = iThreadCount; wsprintf( msg, TEXT( "Target #%d : iThreadCount = %3d" ), iMyId + 1, iThreadCount ); WriteDebugLog( msg ); } else if( dwOuterLoops % 50UL == 0UL ) { wsprintf( msg, TEXT( "Target #%d : Loops %5d, ThreadCnt %3d (Prev %3d)" ), iMyId + 1, dwOuterLoops, iThreadCount, iPrevThreadCount ); WriteDebugLog( msg ); } wsprintf( lpszStatus[ 1 + iMyId * 4 ], TEXT( "Process ID = 0x%04X %04X [ %d %s ]" ), HIWORD( dwTargetProcessId ), LOWORD( dwTargetProcessId ), iThreadCount, ( iThreadCount > 1 ? TEXT( "Threads" ) : TEXT( "Thread" ) ) ); GetLocalTime( &st ); if( iThreadCount != iPrevThreadCount || errorflag ) { dwTotalChanges++; wsprintf( msg, TEXT( "Target #%d : iThreadCount = %3d (Prev = %d)" ), iMyId + 1, iThreadCount, iPrevThreadCount ); WriteDebugLog( msg ); iPrevThreadCount = iThreadCount; errorflag = 0; wsprintf( lpszStatus[ 3 + iMyId * 4 ], TEXT( "%02d:%02d:%02d Target Re-Locked On: OK" ), st.wHour, st.wMinute, st.wSecond ); } else { wsprintf( lpszStatus[ 3 + iMyId * 4 ], TEXT( "%02d:%02d:%02d %s: OK" ), st.wHour, st.wMinute, st.wSecond, dwOuterLoops == 0 ? TEXT( "Started" ) : TEXT( "Calm" ) ); } HANDLE hTarget[ MAX_THREAD_CNT ]; ZeroMemory( hTarget, sizeof( HANDLE ) * MAX_THREAD_CNT ); int iOpenedThread = 0; for( i = 0; i < iThreadCount; i++ ) { hTarget[ i ] = OpenThread( THREAD_SUSPEND_RESUME, FALSE, dwThreadId[ i ] ); if( hTarget[ i ] == NULL ) { wsprintf( msg, TEXT( "[!] Target #%d : OpenThread failed: Thread #%03d, ThreadId 0x%08lX" ), iMyId + 1, i + 1, dwThreadId[ i ] ); WriteDebugLog( msg ); } else { iOpenedThread++; } } // ###---------------- if( iOpenedThread == 0 || iOpenedThread != iThreadCount && iOpenThreadRetry > 10 || iSuspendThreadRetry > 100 || iResumeThreadRetry > 50 ) { GetLocalTime( &st ); if( iResumeThreadRetry > 50 ) { wsprintf( lpszStatus[ 3 + iMyId * 4 ], TEXT( "%02d:%02d:%02d ResumeThread Error" ), st.wHour, st.wMinute, st.wSecond ); // to do // 'unfreeze' } else if( iSuspendThreadRetry > 100 ) { wsprintf( lpszStatus[ 3 + iMyId * 4 ], TEXT( "%02d:%02d:%02d SuspendThread Error" ), st.wHour, st.wMinute, st.wSecond ); } else { wsprintf( lpszStatus[ 3 + iMyId * 4 ], TEXT( "%02d:%02d:%02d OpenThread Error" ), st.wHour, st.wMinute, st.wSecond ); } WriteDebugLog( lpszStatus[ 3 + iMyId * 4 ] ); WriteDebugLog( TEXT( "### Giving up... ###" ) ); lphp->lpTarget->dwProcessId = TARGET_PID_NOT_SET; //? g_dwTargetProcessId[ iMyId ] = TARGET_PID_NOT_SET; if( hProcess ) { SetPriorityClass( hProcess, dwOldPriority ); CloseHandle( hProcess ); } // This is needed as a workaround ? (Possibly this works as a workaround) 1.0 beta6 UpdateStatus( hWnd ); if( ReleaseSemaphore( hSemaphore[ iMyId ], 1L, NULL ) ) { wsprintf( msg, TEXT( "* THREAD_NOT_OPENED #%d : ReleaseSemaphore in Hack()" ), iMyId + 1 ); WriteDebugLog( msg ); } BOOL bMissing = ( PathToProcess( lpszEnemyPath ) == ( DWORD ) -1 ); WriteDebugLog( TEXT("SendMessage Doing...") ); SendMessageCallback( hWnd, WM_USER_STOP, (WPARAM) iMyId, bMissing? TARGET_MISSING : THREAD_NOT_OPENED, (SENDASYNCPROC) DummyCallback, (DWORD) hWnd ); WriteDebugLog( TEXT("SendMessage Done!") ); lphp->lpTarget->dwProcessId = TARGET_PID_NOT_SET; InvalidateRect( hWnd, NULL, TRUE ); return ( bMissing ) ? TARGET_MISSING : THREAD_NOT_OPENED ; } else if( iOpenedThread != iThreadCount ) { for( j = 0; j < i; j++ ) if( hTarget[ j ] ) CloseHandle( hTarget[ j ] ); iOpenThreadRetry++; wsprintf( msg, TEXT( "@ Couldn't open some threads: Retrying #%d..." ), iOpenThreadRetry ); WriteDebugLog( msg ); Sleep( 100UL ); continue; } iOpenThreadRetry = 0; if( g_bHack[ 0 ] || g_bHack[ 1 ] || g_bHack[ 2 ] ) { TCHAR strStatus[ 1024 ] = TEXT( " Limiting CPU load:" ); #ifdef _UNICODE if( IS_JAPANESE ) { MultiByteToWideChar( CP_UTF8, MB_CUTE, S_JPN_2000, -1, strStatus, 1023 ); } else if( IS_FINNISH ) { MultiByteToWideChar( CP_UTF8, MB_CUTE, S_FIN_2000, -1, strStatus, 1023 ); } else if( IS_SPANISH ) { MultiByteToWideChar( CP_UTF8, MB_CUTE, S_SPA_2000, -1, strStatus, 1023 ); } else if( IS_CHINESE_T ) { MultiByteToWideChar( CP_UTF8, MB_CUTE, S_CHI_2000T, -1, strStatus, 1023 ); } else if( IS_CHINESE_S ) { MultiByteToWideChar( CP_UTF8, MB_CUTE, S_CHI_2000S, -1, strStatus, 1023 ); } else if( IS_FRENCH ) { MultiByteToWideChar( CP_UTF8, MB_CUTE, S_FRE_2000, -1, strStatus, 1023 ); } #endif if( g_bHack[ 0 ] ) { lstrcat( strStatus, TEXT( " #1" ) ); } if( g_bHack[ 1 ] ) { lstrcat( strStatus, TEXT( " #2" ) ); } if( g_bHack[ 2 ] && g_dwTargetProcessId[ 2 ] != (DWORD) -1 ) { lstrcat( strStatus, TEXT( " #3" ) ); } wsprintf( lpszStatus[ 12 ], TEXT( "%s" ), strStatus ); } else { lstrcpy( lpszStatus[ 12 ], TEXT( "" ) ); } InvalidateRect( hWnd, &hackrect, FALSE ); for( DWORD dwInnerLoops = 1; dwInnerLoops <= MAX_INNER_LOOPS; dwInnerLoops++ ) { BYTE TimeRed = g_Slider[ iMyId ]; BYTE TimeGreen = (BYTE)( 100 - TimeRed ); for( i = 0; i < iThreadCount; i++ ) { if( ! hTarget[ i ] ) continue; dwPrevSuspendCount = SuspendThread( hTarget[ i ] ); if( ( DWORD ) -1 == dwPrevSuspendCount ) { errorflag = 1; wsprintf( msg, TEXT( "Target #%d : SuspendThread failed (Thread #%03d) : Retry=%d" ), iMyId + 1, i + 1, iSuspendThreadRetry ); WriteDebugLog( msg ); } // else if( dwPrevSuspendCount != 0UL ) // { // WriteDebugLog( TEXT( "### dwPrevSuspendCount != 0UL" ) ); // do // { // dwPrevSuspendCount = ResumeThread( hTarget[ i ] ); // } // while( dwPrevSuspendCount > 1UL ); // } } if( errorflag == 1 ) { iSuspendThreadRetry++; } else { iSuspendThreadRetry = 0; } Sleep( (DWORD) TimeRed ); for( i = 0; i < iThreadCount; i++ ) { if( ! hTarget[ i ] ) continue; DWORD dwPrevSuspendCount = ResumeThread( hTarget[ i ] ); if( ( DWORD ) -1 == dwPrevSuspendCount ) { errorflag = 2; wsprintf( msg, TEXT( "Target #%d : ResumeThread failed: Thread #%03d, ThreadId 0x%08lX, iResumeThreadRetry=%d" ), iMyId + 1, i + 1, dwThreadId[ i ], iResumeThreadRetry ); WriteDebugLog( msg ); } // // else if( dwPrevSuspendCount != 1UL ) // { // WriteDebugLog( TEXT( "### dwPrevSuspendCount != 1UL" ) ); // do // { // dwPrevSuspendCount = ResumeThread( hTarget[ i ] ); // } // while( dwPrevSuspendCount > 1UL ); // } } if( errorflag == 2 ) { iResumeThreadRetry++; } else { iResumeThreadRetry = 0; } if( g_bHack[ iMyId ] == FALSE || errorflag ) { break; } Sleep( (DWORD) TimeGreen ); if( dwInnerLoops % 10UL == 0UL ) { wsprintf( lpszStatus[ 0 + iMyId * 4 ], TEXT( "Target #%d [ -%d%% ] %s" ), iMyId + 1, g_Slider[ iMyId ], ( dwInnerLoops % 20UL == 0UL )? _T( " " ) : #ifdef _UNICODE L"\x25CF" #else "*" #endif ); InvalidateRect( hWnd, &minirect, 0 ); } } for( i = 0; i < iThreadCount; i++ ) { if( hTarget[ i ] ) CloseHandle( hTarget[ i ] ); } } wsprintf( lpszStatus[ 1 + iMyId * 4 ], TEXT( "* Unlimited *" ) ); if( ReleaseSemaphore( hSemaphore[ iMyId ], 1L, (LONG *) NULL ) ) { wsprintf( msg, TEXT( "* Target #%d : ReleaseSemaphore in Hack()" ), iMyId + 1 ); WriteDebugLog( msg ); } else { wsprintf( msg, TEXT( "[!] Target #%d : ReleaseSemaphore failed in Hack(): ErrCode %lu" ), iMyId + 1, GetLastError() ); WriteDebugLog( msg ); } if( hProcess ) { WriteDebugLog( SetPriorityClass( hProcess, dwOldPriority )? TEXT( "Set dwOldPriority: OK" ) : TEXT( "Set dwOldPriority: Failed" ) ); CloseHandle( hProcess ); } lstrcpy( lpszStatus[ 3 + iMyId * 4 ], TEXT( "" ) ); return NORMAL_TERMINATION; }