/* Assumes MulticastLock is Held */ static MC_CLIENT* FindMcClient( CLIENT_HANDLE SdClientHandle, MC_GROUP_ID *pMcGroupId ) { LIST_ITEM *pListItem; size_t compareSize; _DBG_ENTER_LVL(_DBG_LVL_FUNC_TRACE, FindMcClient); compareSize = (pMcGroupId->JoinVersion == 1) ? sizeof(int) + sizeof(IB_GID) : sizeof(MC_GROUP_ID); for (pListItem = QListHead(&MasterMcClientList); pListItem != NULL; pListItem = QListNext(&MasterMcClientList, pListItem)) { MC_CLIENT *pMcClient = (MC_CLIENT *)QListObj(pListItem); if ((pMcClient->SdClientHandle == SdClientHandle) && (pMcClient->pMcGroup != NULL) && (MemoryCompare(&pMcGroupId, &pMcClient->pMcGroup->McGroupId, compareSize) == 0)) { return pMcClient; } } _DBG_LEAVE_LVL( _DBG_LVL_FUNC_TRACE ); return NULL; }
EBS_API ehc_char* StringFindString(ehc_char* s1, ehc_char* s2) { ehc_uint nLen = StringLength(s2); while(s1[0]) { if(!MemoryCompare(s1, s2, nLen)) break; s1++; } return s1[0]?s1:NULL; }
VOID scanSendChatMessage_ScanProc(INT iItem, HWND hwndDlg, PBYTE pbFile) { PIMAGE_NT_HEADERS pNtHdr = PIMAGE_NT_HEADERS(pbFile + PIMAGE_DOS_HEADER(pbFile)->e_lfanew); PIMAGE_SECTION_HEADER pSecHdr = PIMAGE_SECTION_HEADER(pNtHdr + 1); PBYTE pbCode = RvaToPointer(pbFile, pSecHdr[0].VirtualAddress); DWORD dwCodeSize = pSecHdr[0].SizeOfRawData; PBYTE pbRData = RvaToPointer(pbFile, pSecHdr[1].VirtualAddress); DWORD dwRDataSize = pSecHdr[1].SizeOfRawData; PBYTE pbData = RvaToPointer(pbFile, pSecHdr[2].VirtualAddress); DWORD dwDataSize = pSecHdr[2].SizeOfRawData; SetItemStatus(iItem, hwndDlg, "Scanning..."); // scan data section for "Unknown chat type" for(DWORD dwDataIndex = 0; dwDataIndex < dwDataSize - (sizeof("Unknown chat type") - 1); dwDataIndex++) { if(MemoryCompare(&pbData[dwDataIndex], (PBYTE)"Unknown chat type", sizeof("Unknown chat type") - 1)) { // calculate va of found string DWORD dwStringVA = OffsetToRva(pbFile, PtrToUlong(pbData) + dwDataIndex - PtrToUlong(pbFile)); if(dwStringVA) { dwStringVA += pNtHdr->OptionalHeader.ImageBase; // scan code section for 'push dwStringVA' for(DWORD dwCodeIndex = 0; dwCodeIndex < dwCodeSize - 8; dwCodeIndex++) { if(pbCode[dwCodeIndex] == 0x68 && *((PDWORD)&pbCode[dwCodeIndex + 1]) == dwStringVA) { // find beginning of procedure for(DWORD dwCodeIndex2 = dwCodeIndex & 0xFFFFFFF0; dwCodeIndex2; dwCodeIndex2 -= 0x10) { if(pbCode[dwCodeIndex2 - 1] == 0x90 || pbCode[dwCodeIndex2 - 1] == 0xC3 || pbCode[dwCodeIndex2 - 3] == 0xC2) { DWORD dwProcRva = OffsetToRva(pbFile, PtrToUlong(pbCode) + dwCodeIndex2 - PtrToUlong(pbFile)); if(dwProcRva) { GetPPD(iItem, hwndDlg)->dwValue = dwProcRva + pNtHdr->OptionalHeader.ImageBase; SetItemStatus(iItem, hwndDlg, "Success"); return; } } } } } } } } GetPPD(iItem, hwndDlg)->dwValue = 0; SetItemStatus(iItem, hwndDlg, "Fail"); }
/* Assumes MulticastLock is Held */ static MC_GROUP* FindMcGroup(MC_GROUP_ID *pMcGroupId) { LIST_ITEM *pListItem; _DBG_ENTER_LVL(_DBG_LVL_FUNC_TRACE, FindMcGroup); _DBG_INFO(("looking for MGID:%"PRIx64" : %"PRIx64" PortGuid:%"PRIx64"\n", pMcGroupId->McRID.MGID.AsReg64s.H, pMcGroupId->McRID.MGID.AsReg64s.L, pMcGroupId->McRID.PortGID.Type.Global.InterfaceID)); for (pListItem = QListHead(&MasterMcGroupList); pListItem != NULL; pListItem = QListNext(&MasterMcGroupList, pListItem)) { MC_GROUP *pMcGroup = (MC_GROUP *)QListObj(pListItem); ASSERT(pMcGroup != NULL); _DBG_INFO(("MGID:%"PRIx64" : %"PRIx64" PortGuid:%"PRIx64" inuse:%d\n", pMcGroup->McMemberRecord.RID.MGID.AsReg64s.H, pMcGroup->McMemberRecord.RID.MGID.AsReg64s.L, pMcGroup->McMemberRecord.RID.PortGID.Type.Global.InterfaceID, pMcGroup->McGroupInUse)); if (MemoryCompare(&pMcGroup->McMemberRecord.RID, &pMcGroupId->McRID, sizeof(MC_RID)) == 0) { if (pMcGroup->McGroupDelete == FALSE) { _DBG_LEAVE_LVL( _DBG_LVL_FUNC_TRACE ); return pMcGroup; } break; } } _DBG_LEAVE_LVL( _DBG_LVL_FUNC_TRACE ); return NULL; }
void Burger::Filename::SetFromNative(const char *pInput) { Clear(); // Clear out the previous string // Determine the length of the prefix WordPtr uInputLength = StringLength(pInput); const char *pBaseName; WordPtr uBaseNameLength; if (reinterpret_cast<const Word8 *>(pInput)[0]!='/') { // Must I prefix with the current directory? if ((uInputLength>=2) && !MemoryCompare("./",pInput,2)) { // Dispose of "current directory" pInput+=2; uInputLength-=2; } pBaseName = "8:"; uBaseNameLength = 2; } else { if ((uInputLength>9) && !MemoryCompare(pInput,"/Volumes/",9)) { pBaseName = ":"; // Place a leading colon in the output uBaseNameLength = 1; pInput+=9; uInputLength-=9; } else { pBaseName = FileManager::GetBootName(); uBaseNameLength = FileManager::GetBootNameSize(); ++pInput; --uInputLength; } } WordPtr uOutputLength = uBaseNameLength+uInputLength+10; char *pOutput = m_Filename; if (uOutputLength>=sizeof(m_Filename)) { pOutput = static_cast<char *>(Alloc(uOutputLength)); if (!pOutput) { return; } } m_pFilename = pOutput; MemoryCopy(pOutput,pBaseName,uBaseNameLength); pOutput+=uBaseNameLength; // Now, just copy the rest of the path Word uTemp = reinterpret_cast<const Word8*>(pInput)[0]; if (uTemp) { // Any more? do { ++pInput; // Accept char if (uTemp=='/') { uTemp = ':'; } pOutput[0] = uTemp; // Save char ++pOutput; uTemp = reinterpret_cast<const Word8*>(pInput)[0]; // Next char } while (uTemp); // Still more? } // The wrap up... // Make sure it's appended with a colon if (reinterpret_cast<const Word8*>(pOutput)[-1]!=':') { pOutput[0] = ':'; ++pOutput; } pOutput[0] = 0; // End the string with zero }
void BURGER_API Burger::DisplayOpenGL::SetupOpenGL(void) { #if defined(GL_SUPPORTED) const char *pString; #if defined(_DEBUG) // For debug version, dump out OpenGL strings to the console // or logfile.txt { WordPtr uCount = BURGER_ARRAYSIZE(g_StringIndexes); const GLStringIndex_t *pWork = g_StringIndexes; do { // Get the string for the enumeration pString = reinterpret_cast<const char *>(glGetString(pWork->m_eEnum)); // If supported, print it if (pString) { Debug::Message("%s = ",pWork->m_pName); // Use String() because pResult can be long enough to overrun the buffer Debug::String(pString); Debug::String("\n"); } ++pWork; } while (--uCount); } #endif // // Obtain the version of OpenGL found // float fVersion = 0.0f; pString = reinterpret_cast<const char *>(glGetString(GL_VERSION)); if (pString) { if (!MemoryCompare("OpenGL ES ",pString,10)) { pString += 10; } fVersion = AsciiToFloat(pString); } m_fOpenGLVersion = fVersion; // // Obtain the version of the OpenGL shader compiler // fVersion = 0.0f; pString = reinterpret_cast<const char *>(glGetString(GL_SHADING_LANGUAGE_VERSION)); if (pString) { if (!MemoryCompare("OpenGL ES GLSL ES ",pString,18)) { pString += 18; } fVersion = AsciiToFloat(pString); } m_fShadingLanguageVersion = fVersion; // // Obtain the supported compressed texture types // Free(m_pCompressedFormats); m_pCompressedFormats = NULL; Word uTemp = 0; GLint iTemp = 0; glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB,&iTemp); #if defined(_DEBUG) Debug::Message("GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB = %i\n",iTemp); #endif if (iTemp) { GLint iTemp2 = iTemp; GLint *pBuffer = static_cast<GLint *>(Alloc(sizeof(GLint)*iTemp2)); if (pBuffer) { glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS_ARB,pBuffer); uTemp = static_cast<Word>(iTemp); m_pCompressedFormats = reinterpret_cast<Word *>(pBuffer); // Dump the list on debug builds #if defined(_DEBUG) do { Debug::Message("OpenGL supported compressed format 0x%04X\n",pBuffer[0]); ++pBuffer; } while (--iTemp2); #endif } } m_uCompressedFormatCount = uTemp; #endif }
VOID scanGetCharacterGuid_ScanProc(INT iItem, HWND hwndDlg, PBYTE pbFile) { PIMAGE_NT_HEADERS pNtHdr = PIMAGE_NT_HEADERS(pbFile + PIMAGE_DOS_HEADER(pbFile)->e_lfanew); PIMAGE_SECTION_HEADER pSecHdr = PIMAGE_SECTION_HEADER(pNtHdr + 1); PBYTE pbCode = RvaToPointer(pbFile, pSecHdr[0].VirtualAddress); DWORD dwCodeSize = pSecHdr[0].SizeOfRawData; PBYTE pbRData = RvaToPointer(pbFile, pSecHdr[1].VirtualAddress); DWORD dwRDataSize = pSecHdr[1].SizeOfRawData; PBYTE pbData = RvaToPointer(pbFile, pSecHdr[2].VirtualAddress); DWORD dwDataSize = pSecHdr[2].SizeOfRawData; SetItemStatus(iItem, hwndDlg, "Scanning..."); // scan data section for "Player_C.h" for(DWORD dwDataIndex = 0; dwDataIndex < dwDataSize - (sizeof("Player_C.h") - 1); dwDataIndex++) { if(MemoryCompare(&pbData[dwDataIndex], (PBYTE)"Player_C.h", sizeof("Player_C.h") - 1)) { // found "Player_C.h", now scan for beginning of the string DWORD dwStringIndex; for(dwStringIndex = dwDataIndex - 1; dwStringIndex && pbData[dwStringIndex] >= 0x20 && pbData[dwStringIndex] <= 0x7E; dwStringIndex--); dwStringIndex++; // calculate va of found string DWORD dwStringVA = OffsetToRva(pbFile, PtrToUlong(pbData) + dwStringIndex - PtrToUlong(pbFile)); if(dwStringVA) { dwStringVA += pNtHdr->OptionalHeader.ImageBase; // scan code section for 'mov edx, dwStringVA' BYTE bMoveIns[5]; bMoveIns[0] = 0xBA; *((PDWORD)&bMoveIns[1]) = dwStringVA; for(DWORD dwCodeIndex = 0; dwCodeIndex < dwCodeSize - sizeof(bMoveIns); dwCodeIndex++) { if(MemoryCompare(&pbCode[dwCodeIndex], bMoveIns, sizeof(bMoveIns))) { // found mov instruction, make sure next instruction is 'mov ecx, constant' if(pbCode[dwCodeIndex + 5] == 0xB9) { // make sure instruction following 'mov ecx, constant' is a call relative if(pbCode[dwCodeIndex + 10] == 0xE8) { // somewhere before the 'mov edx, dwStringVA' instruction there must be this code: // call relative // push edx // push eax for(DWORD dwCodeIndex2 = dwCodeIndex - 2; dwCodeIndex - dwCodeIndex2 < 20; dwCodeIndex2--) { if(*((PWORD)&pbCode[dwCodeIndex2]) == 0x5052 && pbCode[dwCodeIndex2 - 5] == 0xE8) { // lastly check for a 'push constant' instruction before those two register pushes instruction for(DWORD dwCodeIndex3 = dwCodeIndex2 - 5; dwCodeIndex2 - dwCodeIndex3 < 20; dwCodeIndex3--) { if(pbCode[dwCodeIndex3] == 0x68) { // we need to decode the call relative preceeding the two register pushes // calculate va of next instruction following call DWORD dwFollowingVA = OffsetToRva(pbFile, PtrToUlong(pbCode) + dwCodeIndex2 - PtrToUlong(pbFile)) + pNtHdr->OptionalHeader.ImageBase; if(dwFollowingVA) { GetPPD(iItem, hwndDlg)->dwValue = dwFollowingVA + *((PDWORD)&pbCode[dwCodeIndex2 - 4]); SetItemStatus(iItem, hwndDlg, "Success"); return; } } } } } } } } } } } } GetPPD(iItem, hwndDlg)->dwValue = 0; SetItemStatus(iItem, hwndDlg, "Fail"); }