//----------------------------------------------------------------------------- // Purpose: called when a client joins a server //----------------------------------------------------------------------------- PLUGIN_RESULT CSourcePython::ClientConnect( bool *bAllowConnect, edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen ) { CPointer allowConnect = CPointer((unsigned long) bAllowConnect); CPointer rejectMessage = CPointer((unsigned long) reject); CALL_LISTENERS(ClientConnect, allowConnect, IndexFromEdict(pEntity), pszName, pszAddress, rejectMessage, maxrejectlen); return PLUGIN_OVERRIDE; }
CPointer CPolarSeries::GetPointer() { LPDISPATCH pDispatch; InvokeHelper(0x21, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CPointer(pDispatch); }
CPointer* CBinaryFile::FindSignature(object oSignature) { unsigned char* sigstr = (unsigned char *) PyBytes_AsString(oSignature.ptr()); if (!sigstr) BOOST_RAISE_EXCEPTION(PyExc_ValueError, "Failed to read the given signature."); // Search for a cached signature PythonLog(4, "Searching for a cached signature..."); for (std::list<Signature_t>::iterator iter=m_Signatures.begin(); iter != m_Signatures.end(); iter++) { Signature_t sig = *iter; if (strcmp((const char *) sig.m_szSignature, (const char *) sigstr) == 0) { PythonLog(4, "Found a cached signature!"); return new CPointer(sig.m_ulAddr); } } PythonLog(4, "Could not find a cached signature. Searching in the binary..."); // Search for a signature in the binary int iLength = len(oSignature); CPointer* pPtr = FindSignatureRaw(oSignature); // Found the signature? if (pPtr->IsValid()) { PythonLog(4, "Found a signature in the binary!"); // Add the signature to the cache Signature_t sig_t = {new unsigned char[iLength+1], pPtr->m_ulAddr}; strcpy((char*) sig_t.m_szSignature, (char*) sigstr); m_Signatures.push_back(sig_t); // Return the result return pPtr; } delete pPtr; // Haven't found a match? Then seach for a hooked signature PythonLog(4, "Could not find the signature in the binary. Searching for a hooked signature..."); // Check length of signature if (iLength <= 6) BOOST_RAISE_EXCEPTION(PyExc_ValueError, "Signature is too short to search for a hooked signature."); // Create the hooked signature oSignature = import("binascii").attr("unhexlify")("E92A2A2A2A") + oSignature.slice(5, _); // Try to find the hooked signature pPtr = FindSignatureRaw(oSignature); // Couldn't find it? if (!pPtr->IsValid()) { PythonLog(4, "Could not find a hooked signature."); delete pPtr; } // Yay, we found a match! Now, check if the signature is unique else { PythonLog(4, "Found a hooked signature! Checking if it's unique..."); // Add iLength, so we start searching after the match CPointer new_ptr = CPointer(pPtr->m_ulAddr + iLength); // Got another match after the first one? CPointer* pNext = new_ptr.SearchBytes(oSignature, (m_ulAddr + m_ulSize) - new_ptr.m_ulAddr); bool bIsValid = pNext->IsValid(); delete pNext; if (bIsValid) BOOST_RAISE_EXCEPTION(PyExc_ValueError, "Found more than one hooked signatures. Please pass more bytes."); PythonLog(4, "Signature is unique!"); // It's unique! So, add the original signature to the cache Signature_t sig_t = {new unsigned char[iLength+1], pPtr->m_ulAddr}; strcpy((char*) sig_t.m_szSignature, (char*) sigstr); m_Signatures.push_back(sig_t); // Now, return the result return pPtr; } BOOST_RAISE_EXCEPTION(PyExc_ValueError, "Could not find signature."); return new CPointer(); // To fix a warning. This will never get called. }
CPointer CBoxPlotSeries::GetExtrOut() { LPDISPATCH pDispatch; InvokeHelper(0xd, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CPointer(pDispatch); }
static PyObject* convert(unsigned char* pPtr) { return incref(object(CPointer((unsigned long) pPtr)).ptr()); }