Push strings instead of arrays to not have to deal with odd cell size calculations.

This commit is contained in:
Ryan Stecker
2014-04-05 14:16:39 -05:00
parent a45e33863b
commit 913d4b31f2
2 changed files with 7 additions and 6 deletions
+3 -1
View File
@@ -84,7 +84,9 @@ EBeginAuthSessionResult SteamWorksGSHooks::BeginAuthSession(const void *pAuthTic
{ {
if (this->pOBAS->GetFunctionCount() != 0) if (this->pOBAS->GetFunctionCount() != 0)
{ {
this->pOBAS->PushArray(pAuthTicket, cbAuthTicket); char *pszAuthTicket = reinterpret_cast<char *>(const_cast<void *>(pAuthTicket));
this->pOBAS->PushStringEx(pszAuthTicket, cbAuthTicket, SM_PARAM_STRING_BINARY | SM_PARAM_STRING_COPY, 0);
this->pOBAS->PushCell(cbAuthTicket); this->pOBAS->PushCell(cbAuthTicket);
this->pOBAS->PushCell(steamID.GetAccountID()); this->pOBAS->PushCell(steamID.GetAccountID());
this->pOBAS->Execute(NULL); this->pOBAS->Execute(NULL);
+4 -5
View File
@@ -588,8 +588,7 @@ static cell_t sm_GetHTTPResponseBodyCallback(IPluginContext *pContext, const cel
return 0; return 0;
} }
size_t celllen = ((size / sizeof(cell_t)) + 1); char *pBuffer = new char[size+1];
cell_t *pBuffer = new cell_t[celllen+1];
if (pHTTP->GetHTTPResponseBodyData(pRequest->request, reinterpret_cast<uint8_t *>(pBuffer), size) == false) if (pHTTP->GetHTTPResponseBodyData(pRequest->request, reinterpret_cast<uint8_t *>(pBuffer), size) == false)
{ {
@@ -597,10 +596,10 @@ static cell_t sm_GetHTTPResponseBodyCallback(IPluginContext *pContext, const cel
return 0; return 0;
} }
pBuffer[celllen] = '\0'; /* Incase users do something bad; we want to protect userspace; kind of. */ pBuffer[size] = '\0'; /* Incase users do something bad; we want to protect userspace; kind of. */
pFunction->PushArray(pBuffer, celllen); /* Strings do a copy... it's really bad :( */ pFunction->PushStringEx(pBuffer, size, SM_PARAM_STRING_BINARY | SM_PARAM_STRING_COPY, 0);
pFunction->PushCell(params[3]); pFunction->PushCell(params[3]);
pFunction->PushCell(celllen); pFunction->PushCell(size);
pFunction->Execute(NULL); pFunction->Execute(NULL);
delete [] pBuffer; delete [] pBuffer;