From: Jeffrey D. <ha...@us...> - 2003-09-26 22:46:26
|
Log Message: ----------- Yay for no splash =) Modified Files: -------------- /cvsroot/decaldev/source/Inject: Inject.cpp Revision Data ------------- Index: Inject.cpp =================================================================== RCS file: /cvsroot/decaldev/source/Inject/Inject.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- Inject.cpp 8 Sep 2003 23:37:43 -0000 1.28 +++ Inject.cpp 26 Sep 2003 22:07:28 -0000 1.29 @@ -75,12 +75,14 @@ static bool bDualLog = false; static bool bWindowed = false; +static bool bNoSplash = false; static cHookDescriptor _hooksDualLog[] = { { eByName, _T( "kernel32.dll" ), _T( "CreateSemaphoreA" ), 102, reinterpret_cast< DWORD >( Replacement_CreateSemaphoreA ), 0 }, }; bool CheckClientVersion( MSXML::IXMLDOMDocument *pDoc ); bool PatchWindowMode( MSXML::IXMLDOMDocument *pDoc ); +bool PatchNoSplash( MSXML::IXMLDOMDocument *pDoc ); HINSTANCE hAlphaBlendDLL; @@ -156,6 +158,13 @@ } + // Splash hax patches + dwReg = 0; + if( key.QueryDWORDValue( "NoSplash", dwReg ) == ERROR_SUCCESS ) + { + if( dwReg ) + bNoSplash = PatchNoSplash( pPatchesDoc ); + } } @@ -415,11 +424,17 @@ MSXML::IXMLDOMElementPtr pNode; MSXML::IXMLDOMNodeListPtr pNodes = pDoc->selectNodes( _bstr_t( "/patches/patch" ) ); - bool bWindowPattern = false, bWindowReplaceOffset = false, bWindowReplace = false, bWindowMaxOffset = false; - char *szPatchPattern; - unsigned char lReplace; - long lReplaceOffset; - long lMaxOffset; + bool bWindowPattern = false, + bWindowReplaceOffset = false, + bWindowReplace = false, + bWindowMaxOffset = false; + + char *szPatchPattern; + + unsigned char byteReplace; + + long lReplaceOffset, + lMaxOffset; for( pNode = pNodes->nextNode(); pNode.GetInterfacePtr() != NULL; pNode = pNodes->nextNode() ) { @@ -440,7 +455,7 @@ if( stricmp( szName, "WindowedModeReplace" ) == 0 ) { _variant_t vReplace = pNode->getAttribute( _bstr_t( "value" ) ); - lReplace = wcstoul( vReplace.bstrVal, NULL, 16 ); + byteReplace = wcstoul( vReplace.bstrVal, NULL, 16 ); bWindowReplace = true; continue; } @@ -471,19 +486,9 @@ unsigned char *szPatternArray = new unsigned char[ iLen ]; memset( szPatternArray, 0, iLen ); -/* FILE *f = fopen( "C:\\decal\\log.txt", "a+" ); - fprintf( f, "iLen = %d\nszPatchPattern = %s\nszPatternArray = ", iLen, szPatchPattern ); */ - int i; - for( i = 0; i < iLen; ++i ) -// { szPatternArray[ i ] = strtoul( szPatchPattern + (i*3), NULL, 16 ); -// fprintf( f, "%02X ", szPatternArray[ i ] ); -// } - -/* fprintf( f, "\n" ); - fclose( f );*/ bool bAbort = true; @@ -493,7 +498,7 @@ if( *pAddy == szPatternArray[ 0 ] ) { // see if entire pattern matches. - if( strcmp( reinterpret_cast< const char * >( szPatternArray ) + 1, reinterpret_cast< char * >( pAddy ) + 1 ) == 0 ) + if( memcmp( reinterpret_cast< const char * >( szPatternArray ) + 1, reinterpret_cast< char * >( pAddy ) + 1, iLen - 1 ) == 0 ) { // yahoo? ... bAbort = false; @@ -508,7 +513,187 @@ DWORD dwOldProtect, dwNewProtect; VirtualProtect( reinterpret_cast< void * >( pAddy ), 1, PAGE_READWRITE, &dwOldProtect ); - pAddy[ 0 ] = lReplace; + pAddy[ 0 ] = byteReplace; + VirtualProtect( reinterpret_cast< void * >( pAddy ), 1, dwOldProtect, &dwNewProtect ); + + return true; +} + +bool PatchNoSplash( MSXML::IXMLDOMDocument *pDoc ) +{ + if( pDoc == NULL ) + return false; + + USES_CONVERSION; + + MSXML::IXMLDOMElementPtr pNode; + MSXML::IXMLDOMNodeListPtr pNodes = pDoc->selectNodes( _bstr_t( "/patches/patch" ) ); + + bool bNoSplashPattern1 = false, + bNoSplashPattern2 = false, + bNoSplashReplaceOffset1 = false, + bNoSplashReplaceOffset2 = false, + bNoSplashReplace1 = false, + bNoSplashReplace2 = false, + bNoSplashMaxOffset1 = false, + bNoSplashMaxOffset2 = false; + + char *szPatchPattern1, + *szPatchPattern2; + + unsigned char byteReplace1, + byteReplace2; + + long lReplaceOffset1, + lReplaceOffset2, + lMaxOffset1, + lMaxOffset2; + + for( pNode = pNodes->nextNode(); pNode.GetInterfacePtr() != NULL; pNode = pNodes->nextNode() ) + { + if( bNoSplashPattern1 && bNoSplashPattern2 && bNoSplashReplaceOffset1 && bNoSplashReplaceOffset2 && bNoSplashReplace1 && bNoSplashReplace2 && bNoSplashMaxOffset1 && bNoSplashMaxOffset2 ) + break; + + _variant_t vName = pNode->getAttribute( _bstr_t( "name" ) ); + char *szName = OLE2A( vName.bstrVal ); + + if( stricmp( szName, "SplashHax1Pattern" ) == 0 ) + { + _variant_t vPatchPattern = pNode->getAttribute( _bstr_t( "value" ) ); + szPatchPattern1 = OLE2A( vPatchPattern.bstrVal ); + bNoSplashPattern1 = true; + continue; + } + + if( stricmp( szName, "SplashHax2Pattern" ) == 0 ) + { + _variant_t vPatchPattern = pNode->getAttribute( _bstr_t( "value" ) ); + szPatchPattern2 = OLE2A( vPatchPattern.bstrVal ); + bNoSplashPattern2 = true; + continue; + } + + if( stricmp( szName, "SplashHax1Replace" ) == 0 ) + { + _variant_t vReplace = pNode->getAttribute( _bstr_t( "value" ) ); + byteReplace1 = wcstoul( vReplace.bstrVal, NULL, 16 ); + bNoSplashReplace1 = true; + continue; + } + + if( stricmp( szName, "SplashHax2Replace" ) == 0 ) + { + _variant_t vReplace = pNode->getAttribute( _bstr_t( "value" ) ); + byteReplace2 = wcstoul( vReplace.bstrVal, NULL, 16 ); + bNoSplashReplace2 = true; + continue; + } + + if( stricmp( szName, "SplashHax1ReplaceOffset" ) == 0 ) + { + _variant_t vReplaceOffset = pNode->getAttribute( _bstr_t( "value" ) ); + lReplaceOffset1 = wcstoul( vReplaceOffset.bstrVal, NULL, 16 ) - 1; // Arrays are 0 indexed in c++ + bNoSplashReplaceOffset1 = true; + continue; + } + + if( stricmp( szName, "SplashHax2ReplaceOffset" ) == 0 ) + { + _variant_t vReplaceOffset = pNode->getAttribute( _bstr_t( "value" ) ); + lReplaceOffset2 = wcstoul( vReplaceOffset.bstrVal, NULL, 16 ) - 1; // Arrays are 0 indexed in c++ + bNoSplashReplaceOffset2 = true; + continue; + } + + if( stricmp( szName, "SplashHax1MaxOffset" ) == 0 ) + { + _variant_t vMaxOffset = pNode->getAttribute( _bstr_t( "value" ) ); + lMaxOffset1 = wcstoul( vMaxOffset.bstrVal, NULL, 16 ); + bNoSplashMaxOffset1 = true; + continue; + } + + if( stricmp( szName, "SplashHax2MaxOffset" ) == 0 ) + { + _variant_t vMaxOffset = pNode->getAttribute( _bstr_t( "value" ) ); + lMaxOffset2 = wcstoul( vMaxOffset.bstrVal, NULL, 16 ); + bNoSplashMaxOffset2 = true; + continue; + } + } + + if( !(bNoSplashPattern1 && bNoSplashPattern2 && bNoSplashReplaceOffset1 && bNoSplashReplaceOffset2 && bNoSplashReplace1 && bNoSplashReplace2 && bNoSplashMaxOffset1 && bNoSplashMaxOffset2) ) + return false; + + unsigned char *pAddy = reinterpret_cast< unsigned char * >( 0x400000 ); + + int iLen = strlen( szPatchPattern1 + 1 ) / 3 + 1; + unsigned char *szPatternArray1 = new unsigned char[ iLen ]; + memset( szPatternArray1, 0, iLen ); + + int i; + for( i = 0; i < iLen; ++i ) + szPatternArray1[ i ] = strtoul( szPatchPattern1 + (i*3), NULL, 16 ); + + bool bAbort1 = true; + + for( i = 0; i < lMaxOffset1; ++i, ++pAddy ) + { + // peek at current byte + if( *pAddy == szPatternArray1[ 0 ] ) + { + // see if entire pattern matches. + if( memcmp( reinterpret_cast< const char * >( szPatternArray1 ) + 1, reinterpret_cast< char * >( pAddy ) + 1, iLen - 1 ) == 0 ) + { + // yahoo? ... + bAbort1 = false; + pAddy += lReplaceOffset1; + break; + } + } + } + + if( bAbort1 ) + return false; + + DWORD dwOldProtect, dwNewProtect; + VirtualProtect( reinterpret_cast< void * >( pAddy ), 1, PAGE_READWRITE, &dwOldProtect ); + pAddy[ 0 ] = byteReplace1; + VirtualProtect( reinterpret_cast< void * >( pAddy ), 1, dwOldProtect, &dwNewProtect ); + + + pAddy = reinterpret_cast< unsigned char * >( 0x400000 ); + + iLen = strlen( szPatchPattern2 + 1 ) / 3 + 1; + unsigned char *szPatternArray2 = new unsigned char[ iLen ]; + memset( szPatternArray2, 0, iLen ); + + for( i = 0; i < iLen; ++i ) + szPatternArray2[ i ] = strtoul( szPatchPattern2 + (i*3), NULL, 16 ); + + bool bAbort2 = true; + + for( i = 0; i < lMaxOffset2; ++i, ++pAddy ) + { + // peek at current byte + if( *pAddy == szPatternArray2[ 0 ] ) + { + // see if entire pattern matches. + if( memcmp( reinterpret_cast< const char * >( szPatternArray2 ) + 1, reinterpret_cast< char * >( pAddy ) + 1, iLen - 1 ) == 0 ) + { + // yahoo? ... + bAbort2 = false; + pAddy += lReplaceOffset2; + break; + } + } + } + + if( bAbort2 ) + return false; + + VirtualProtect( reinterpret_cast< void * >( pAddy ), 1, PAGE_READWRITE, &dwOldProtect ); + pAddy[ 0 ] = byteReplace2; VirtualProtect( reinterpret_cast< void * >( pAddy ), 1, dwOldProtect, &dwNewProtect ); return true; |