Esempio n. 1
0
static CSSM_RETURN mds_CheckParamters(
	const BioAPI_MEMORY_FUNCS * pMemoryFunctions,
	MDS_FUNCS * pDlFunctions,
	MDS_HANDLE *hMds)
{
	if (IsBadReadPtr(pMemoryFunctions, sizeof(BioAPI_MEMORY_FUNCS)) ||
		IsBadCodePtr((CSSM_PROC_ADDR)pMemoryFunctions->Malloc_func) ||
		IsBadCodePtr((CSSM_PROC_ADDR)pMemoryFunctions->Free_func) ||
		IsBadCodePtr((CSSM_PROC_ADDR)pMemoryFunctions->Calloc_func) ||
		IsBadCodePtr((CSSM_PROC_ADDR)pMemoryFunctions->Realloc_func))
	{
		return CSSMERR_DL_INVALID_POINTER;
	}

	if (IsBadWritePtr(pDlFunctions, sizeof(MDS_FUNCS_PTR)))
	{
		return CSSMERR_DL_INVALID_POINTER;
	}

	if (IsBadWritePtr(hMds, sizeof(MDS_HANDLE)))
	{
		return CSSMERR_DL_INVALID_POINTER;
	}

	return CSSM_OK;
}
Esempio n. 2
0
char *GetGroupCountsText(struct ClcData *dat,struct ClcContact *contact)
{
	static char szName[32];
	int onlineCount,totalCount;
	struct ClcGroup *group,*topgroup;
  if (IsBadCodePtr((FARPROC)contact) || IsBadCodePtr((FARPROC)dat)) return NULL;
	if(contact->type!=CLCIT_GROUP || !(dat->exStyle&CLS_EX_SHOWGROUPCOUNTS))
		return NULL;
	group=topgroup=contact->group;
	onlineCount=0;
  if (IsBadCodePtr((FARPROC)group)) return NULL;
	totalCount=group->totalMembers;
	group->scanIndex=0;
	for(;;) {
		if(group->scanIndex==group->contactCount) {
			if(group==topgroup) break;
			group=group->parent;
		}
		else if(group->contact[group->scanIndex].type==CLCIT_GROUP) {
			group=group->contact[group->scanIndex].group;
			group->scanIndex=0;
			totalCount+=group->totalMembers;
			continue;
		}
		else if(group->contact[group->scanIndex].type==CLCIT_CONTACT)
			if(group->contact[group->scanIndex].flags&CONTACTF_ONLINE && !group->contact[group->scanIndex].isSubcontact) onlineCount++;
		group->scanIndex++;
	}
	if(onlineCount==0 && dat->exStyle&CLS_EX_HIDECOUNTSWHENEMPTY) return NULL;
	_snprintf(szName,sizeof(szName),"(%u/%u)",onlineCount,totalCount);
	return mir_strdup(szName);
}
Esempio n. 3
0
/**
 * main
 * 
 * executable entry point
 */
INT __cdecl main(INT argc, CHAR **argv)
{
    BOOL ResultValue = 0;
  
    /*
     * Initialize the PAL and return FAILURE if this fails
     */

    if(0 != (PAL_Initialize(argc, argv)))
    {
        return FAIL;
    }     

    /* This should be readable, and return 0 */
    ResultValue = IsBadCodePtr((FARPROC)main);
    if(ResultValue != 0) 
    {
        Fail("ERROR: IsBadCodePtr returned %d instead of 0, when pointing "
             "at readable memory.\n",ResultValue);    
    }

    /* 0x00 is usually unreadable memory so the function should 
       return non zero */
    ResultValue = IsBadCodePtr((FARPROC)0x00);

    if(ResultValue == 0)
    {
        Fail("ERROR: IsBadCodePtr returned %d instead of non zero  "
             "when checking on unreadable memory.\n",ResultValue);
    }

    PAL_Terminate();
    return PASS;
}
int __cdecl MyStrCmp (const char *a, const char *b)
{
	
	if (a==NULL&&b==NULL) return 0;
	if ((int)a<1000||(int)b<1000||IsBadCodePtr((FARPROC)a)||IsBadCodePtr((FARPROC)b)) 
	{
		return 1;
	}
	//TRACE("MY\r\n");
	//undef();
	return (strcmp(a,b));
};
Esempio n. 5
0
BioAPI_RETURN BioAPI mdsutil_GetRecord(CSSM_DL_DB_HANDLE hDLDB,
									  CSSM_QUERY Query,
									  CSSM_DB_RECORDTYPE RecordType,
									  uint32 NumAttributes,
									  CSSM_HANDLE_PTR ResultsHandle,
									  CSSM_DB_ATTRIBUTE_DATA *OutputAttributeData)
{
	CSSM_DB_UNIQUE_RECORD_PTR RecordId = NULL;
	CSSM_DB_RECORD_ATTRIBUTE_DATA OutputAttributes;
	BioAPI_RETURN retValue = CSSM_OK;

	memset (&OutputAttributes, 0, sizeof (CSSM_DB_RECORD_ATTRIBUTE_DATA));

	/* We want to get NumAttributes back */
	OutputAttributes.DataRecordType = RecordType;
	OutputAttributes.NumberOfAttributes = NumAttributes;
	OutputAttributes.AttributeData = OutputAttributeData;

	if (0 == *ResultsHandle)
	{
		if( !IsBadCodePtr((CSSM_PROC_ADDR)MDSFuncs.DataGetFirst))
		{
			retValue = MDSFuncs.DataGetFirst (hDLDB, /* DLDBHandle */
											  &Query,
											  ResultsHandle,
											  &OutputAttributes,
											  NULL,
											  &RecordId);
		}
	} else {
		if( !IsBadCodePtr((CSSM_PROC_ADDR)MDSFuncs.DataGetNext))
		{
			retValue = MDSFuncs.DataGetNext (hDLDB, /* DLDBHandle */
											 *ResultsHandle,
											 &OutputAttributes,
											 NULL,
											 &RecordId);
		}
	}

	if (retValue != CSSM_OK)
		return retValue;

	if (!IsBadCodePtr((CSSM_PROC_ADDR)MDSFuncs.FreeUniqueRecord))
		MDSFuncs.FreeUniqueRecord(hDLDB, RecordId);

	return (retValue);
}
Esempio n. 6
0
// Searches for [cOrigFuncName] starting from [pOrigFirstThunk].
// Only used on Win9x, where patching by pointer doesn't seem to work
int PatchFuncByName(HMODULE hMod, PIMAGE_THUNK_DATA pOrigFirstThunk, PIMAGE_THUNK_DATA pImpFirstThunk, char* cOrigFuncName, void* pNewFunc)
{
	PIMAGE_THUNK_DATA pOT, pIT;

	// Verify that the newFunc is valid
	if(!pNewFunc || IsBadCodePtr((FARPROC)pNewFunc))	return 0;

	for(pOT = pOrigFirstThunk, pIT = pImpFirstThunk; pOT->u1.Function; pOT++, pIT++)
	{
		if((pOT->u1.Ordinal & IMAGE_ORDINAL_FLAG) != IMAGE_ORDINAL_FLAG)
        {
			PIMAGE_IMPORT_BY_NAME pByName =(PIMAGE_IMPORT_BY_NAME)((DWORD)hMod+(DWORD)(pOT->u1.AddressOfData));
            if(pByName->Name[0] == '\0')
            {
                return 0;
            }
            
            if(_stricmp(cOrigFuncName, (char*)pByName->Name) == 0)
            {
				return PatchFunc(pIT, pNewFunc);
			}
		}
	}
	// Function not found
	return 0;
}
Esempio n. 7
0
static int AddItemToGroup(struct ClcGroup *group,int iAboveItem)
{
	if (group==NULL) return 0;

	if(++group->contactCount>group->allocedCount) {
		group->allocedCount+=GROUP_ALLOCATE_STEP;
      //  if (group->contact) mir_free(group->contact);
		if(group->contact)	
		group->contact=(struct ClcContact*)mir_realloc(group->contact,sizeof(struct ClcContact)*group->allocedCount);
			else 
			group->contact=(struct ClcContact*)mir_alloc(sizeof(struct ClcContact)*group->allocedCount);
			
		if (group->contact==NULL||IsBadCodePtr((FARPROC)group->contact))
		{
			TRACE("!!!Bad Realloc AddItemToGroup");
			DebugBreak();
		}
	}
	memmove(group->contact+iAboveItem+1,group->contact+iAboveItem,sizeof(struct ClcContact)*(group->contactCount-iAboveItem-1));
    memset(&(group->contact[iAboveItem]),0,sizeof((group->contact[iAboveItem])));
	group->contact[iAboveItem].type=CLCIT_DIVIDER;
	//group->contact[iAboveItem].flags=0;
	memset(group->contact[iAboveItem].iExtraImage,0xFF,sizeof(group->contact[iAboveItem].iExtraImage));
  group->contact[iAboveItem].szText=NULL;
  group->contact[iAboveItem].szSecondLineText=NULL;
  group->contact[iAboveItem].szThirdLineText=NULL;
  group->contact[iAboveItem].SubAllocated=0;
  group->contact[iAboveItem].subcontacts=NULL;
	group->contact[iAboveItem].SubExpanded=0;
	
	ClearRowByIndexCache();
	return iAboveItem;
}
Esempio n. 8
0
NDASUSER_LINKAGE
HNDASEVENTCALLBACK
NDASUSERAPI
NdasRegisterEventCallback(
	NDASEVENTPROC lpEventProc, LPVOID lpContext)
{
	if (IsBadCodePtr(reinterpret_cast<FARPROC>(lpEventProc))) {
		::SetLastError(NDASUSER_ERROR_INVALID_PARAMETER);
		return FALSE;
	}

	BOOL fSuccess = _pEventSubscriber->Initialize();
	if (!fSuccess) {
		DPErrorEx(_FT("Event Subscriber initialization failed: "));
		return FALSE;
	}
	
	HNDASEVENTCALLBACK hCallback = 
		_pEventSubscriber->AddCallback(lpEventProc, lpContext);

	if (NULL == hCallback) {
		DPErrorEx(_FT("Adding callback function failed: "));
		return FALSE;
	}

	return hCallback;
}
Esempio n. 9
0
void EnsureVisible(HWND hwnd,struct ClcData *dat,int iItem,int partialOk)
{
	int itemy,newy;
	int moved=0;
	RECT clRect;


	if (dat==NULL||IsBadCodePtr((void *)dat)||!dat->row_heights) 
	{
		TRACE("dat is null __FILE____LINE__");
		return ;
	};

	GetClientRect(hwnd,&clRect);
	itemy=RowHeights_GetItemTopY(dat,iItem);
	if(partialOk) {
		if(itemy+dat->row_heights[iItem]-1<dat->yScroll) {newy=itemy; moved=1;}
		else if(itemy>=dat->yScroll+clRect.bottom) {newy=itemy-clRect.bottom+dat->row_heights[iItem]; moved=1;}
	}
	else {
		if(itemy<dat->yScroll) {newy=itemy; moved=1;}
		else if(itemy>=dat->yScroll+clRect.bottom-dat->row_heights[iItem]) {newy=itemy-clRect.bottom+dat->row_heights[iItem]; moved=1;}
	}
	if(moved)
		ScrollTo(hwnd,dat,newy,0);
}
Esempio n. 10
0
HRESULT
WINAPI
DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA lpCallback,
                       LPVOID lpContext,
                       DWORD dwFlags)
{
    HKEY hKey;
    DWORD cbData = 0;
    DWORD Value = 0;
    LONG rc;
    BOOL  EnumerateAttachedSecondaries = FALSE;
    DWORD privateDWFlags = 0;
    CHAR strMsg[RC_STRING_MAX_SIZE];
    HRESULT retVal = DDERR_INVALIDPARAMS;

    DX_WINDBG_trace();

    if ((IsBadCodePtr((LPVOID)lpCallback) == 0) &&
       ((dwFlags & ~(DDENUM_NONDISPLAYDEVICES |
                    DDENUM_DETACHEDSECONDARYDEVICES |
                    DDENUM_ATTACHEDSECONDARYDEVICES)) == 0))
    {
        LoadStringA(hDllModule, STR_PRIMARY_DISPLAY, (LPSTR)&strMsg, RC_STRING_MAX_SIZE);

        rc = RegOpenKeyA(HKEY_LOCAL_MACHINE, REGSTR_PATH_DDHW, &hKey);
        if (rc == ERROR_SUCCESS)
        {
            /* Enumerate Attached Secondaries */
            cbData = sizeof(DWORD);
            rc = RegQueryValueExA(hKey, "EnumerateAttachedSecondaries", NULL, NULL, (LPBYTE)&Value, &cbData);
            if (rc == ERROR_SUCCESS)
            {
                if (Value != 0)
                {
                    EnumerateAttachedSecondaries = TRUE;
                    privateDWFlags = DDENUM_ATTACHEDSECONDARYDEVICES;
                }
            }
            RegCloseKey(hKey);
        }

        /* Call the user supplied callback function */
        rc = lpCallback(NULL, strMsg, "display", lpContext, NULL);

        /* If the callback function returns DDENUMRET_CANCEL, we will stop enumerating devices */
        if(rc == DDENUMRET_CANCEL)
        {
            retVal = DD_OK;
        }
        else
        {
            // not finished
            retVal = DDERR_UNSUPPORTED;
        }
    }

    return retVal;
}
Esempio n. 11
0
// Helper function
void PreReadConsoleInput(HANDLE hConIn, DWORD nFlags/*enum CEReadConsoleInputFlags*/, CESERVER_CONSOLE_APP_MAPPING** ppAppMap = NULL)
{
	#if defined(_DEBUG) && defined(PRE_PEEK_CONSOLE_INPUT)
	INPUT_RECORD ir = {}; DWORD nRead = 0, nBuffer = 0;
	BOOL bNumGot = GetNumberOfConsoleInputEvents(hConIn, &nBuffer);
	BOOL bConInPeek = nBuffer ? PeekConsoleInputW(hConIn, &ir, 1, &nRead) : FALSE;
	#endif

	if (gbPowerShellMonitorProgress)
	{
		CheckPowershellProgressPresence();
	}

	if (gbCurDirChanged)
	{
		gbCurDirChanged = false;

		if (ghConEmuWndDC)
		{
			if (gFarMode.cbSize
				&& gFarMode.OnCurDirChanged
				&& !IsBadCodePtr((FARPROC)gFarMode.OnCurDirChanged))
			{
				gFarMode.OnCurDirChanged();
			}
			else
			{
				CmdArg szDir;
				if (GetDirectory(szDir) > 0)
				{
					// Sends CECMD_STORECURDIR into RConServer
					SendCurrentDirectory(ghConWnd, szDir);
				}
			}
		}
	}

	if (!(nFlags & rcif_Peek))
	{
		// On the one hand - there is a problem with unexpected Enter/Space keypress
		// github#19: After executing php.exe from command prompt (it runs by Enter KeyDown)
		//            the app gets in its input queue unexpected Enter KeyUp
		// On the other hand - application must be able to understand if the key was released
		// Powershell's 'get-help Get-ChildItem -full | out-host -paging' or Issue 1927 (jilrun.exe)
		CESERVER_CONSOLE_APP_MAPPING* pAppMap = gpAppMap ? gpAppMap->Ptr() : NULL;
		if (pAppMap)
		{
			DWORD nSelfPID = GetCurrentProcessId();
			if (nFlags & rcif_LLInput)
				pAppMap->nReadConsoleInputPID = nSelfPID;
			else
				pAppMap->nReadConsolePID = nSelfPID;
			pAppMap->nLastReadInputPID = nSelfPID;
			pAppMap->nActiveAppFlags = gnExeFlags;
			if (ppAppMap) *ppAppMap = pAppMap;
		}
	}
}
Esempio n. 12
0
//-----------------------------------------------------------------------------
// Name: SetDropDownMenuCallBack
// Object: set drop down menu callback
// Parameters :
//     in  : tagDropDownMenuCallBack pDropDownMenuCallBack : pointer to callback
//           PVOID UserParam : user parameter that will be transmit to callback
//     out :
//     return : TRUE on success, FALSE on error
//-----------------------------------------------------------------------------
BOOL CToolbar::SetDropDownMenuCallBack(tagDropDownMenuCallBack pDropDownMenuCallBack,PVOID UserParam)
{
    if (IsBadCodePtr((FARPROC)pDropDownMenuCallBack))
        return FALSE;

    this->pDropDownMenuCallBack=pDropDownMenuCallBack;
    this->DropDownMenuUserParam=UserParam;
    return TRUE;
}
Esempio n. 13
0
File: ifs.c Progetto: pstrealer/wine
/******************************************************************************
 *		IsValidInterface	[OLE32.@]
 *
 * Determines whether a pointer is a valid interface.
 *
 * PARAMS
 *  punk [I] Interface to be tested.
 *
 * RETURNS
 *  TRUE, if the passed pointer is a valid interface, or FALSE otherwise.
 */
BOOL WINAPI IsValidInterface(LPUNKNOWN punk)
{
	return !(
		IsBadReadPtr(punk,4)					||
		IsBadReadPtr(punk->lpVtbl,4)				||
		IsBadReadPtr(punk->lpVtbl->QueryInterface,9)	||
		IsBadCodePtr((FARPROC)punk->lpVtbl->QueryInterface)
	);
}
Esempio n. 14
0
//-----------------------------------------------------------------------------
// Name: SetElementEventsCallBackEx
// Object: set extended document events callback
// Parameters :
//     in  : 
//     out : 
//     return : 
//-----------------------------------------------------------------------------
BOOL CElementEvents::SetElementEventsCallBackEx(pfElementEventsCallBackEx ElementEventsCallBackEx,LPVOID UserParam)
{
    if (IsBadCodePtr((FARPROC)ElementEventsCallBackEx) && (ElementEventsCallBackEx!=0))
        return FALSE;

    this->ElementEventsCallBackEx=ElementEventsCallBackEx;
    this->ElementEventsCallBackExUserParam=UserParam;

    return TRUE;
}
Esempio n. 15
0
//-----------------------------------------------------------------------------
// Name: SetElementsEventsCallBack
// Object: set simple document events callback
// Parameters :
//     in  : 
//     out : 
//     return : 
//-----------------------------------------------------------------------------
BOOL CElementEvents::SetElementEventsCallBack(pfElementEventsCallBack ElementEventsCallBack,LPVOID UserParam)
{
    if (IsBadCodePtr((FARPROC)ElementEventsCallBack) && (ElementEventsCallBack!=0))
        return FALSE;

    this->ElementEventsCallBack=ElementEventsCallBack;
    this->ElementEventsCallBackUserParam=UserParam;

    return TRUE;
}
Esempio n. 16
0
	uint32_t CalculateLength() {
		uint32_t dwIndex = 0;
		if (!m_pOriginalVMTable) return 0;
		for (dwIndex = 0; m_pOriginalVMTable[dwIndex]; dwIndex++) {
			if (IsBadCodePtr((FARPROC)m_pOriginalVMTable[dwIndex])) {
				break;
			}
		}
		return dwIndex;
	}
Esempio n. 17
0
_inline int MyStrLen (const char *a)	
 	 {	
 	 	
 	         if (a==NULL) return 0;	
 	         if ((int)a<1000||IsBadCodePtr((FARPROC)a))	
 	         {	
 	                 return 0;	
 	         }	
 	         //TRACE("MY\r\n");	
 	         //undef();	
 	         return (strlen(a));	
 	 };	
Esempio n. 18
0
//-----------------------------------------------------------------------------
// Name: SetElementsEventsCallBackEx
// Object: set extended document events callback
// Parameters :
//     in  : 
//     out : 
//     return : 
//-----------------------------------------------------------------------------
BOOL CHtmlViewer::SetElementsEventsCallBackEx(pfElementEventsCallBackEx ElementEventsCallBackEx,LPVOID UserParam)
{
    if (IsBadCodePtr((FARPROC)ElementEventsCallBackEx) && (ElementEventsCallBackEx!=0))
        return FALSE;

    this->ElementEventsCallBackEx=ElementEventsCallBackEx;
    this->ElementEventsCallBackExUserParam=UserParam;

    if (this->pDocumentElementEvents)
        this->pDocumentElementEvents->SetElementEventsCallBackEx(this->ElementEventsCallBackEx,this->ElementEventsCallBackExUserParam);

    return TRUE;
}
Esempio n. 19
0
const void* rocs_lib_getProc( iOLib inst, const char* procname ) {
  void* proc = NULL;
#ifdef __ROCS_LIB__
  iOLibData o = Data(inst);
  proc = GetProcAddress( o->lh, procname );
  if( proc == NULL || IsBadCodePtr(proc) ) {
    TraceOp.trc( name, TRCLEVEL_EXCEPTION, __LINE__, 9999, "rocs_lib_getProc [%s:%s] failed. rc=%d", o->name, procname, GetLastError() );
    return NULL;
  }
  TraceOp.trc( name, TRCLEVEL_INFO, __LINE__, 9999, "rocs_lib_getProc OK [%s:%s]", o->name, procname );
#endif
  return proc;
}
Esempio n. 20
0
void FreeProtocolData(void)
{
	// free protocol data
	int nParts = SendMessage(pcli->hwndStatus, SB_GETPARTS, 0, 0);
	for (int nPanel = 0; nPanel < nParts; nPanel++) {
		ProtocolData *PD = (ProtocolData *)SendMessage(pcli->hwndStatus, SB_GETTEXT, nPanel, 0);
		if (PD != NULL && !IsBadCodePtr((FARPROC)PD)) {
			SendMessage(pcli->hwndStatus, SB_SETTEXT, (WPARAM)nPanel | SBT_OWNERDRAW, 0);
			if (PD->RealName) mir_free(PD->RealName);
			if (PD) mir_free(PD);
		}
	}
}
Esempio n. 21
0
void FreeAndNil(void **p)
{
	if (p!=NULL)
	{
		if (*p!=NULL)
		{
			if (!IsBadCodePtr(*p))
			{
				mir_free(*p);
			}
			*p=NULL;
		}
	}
}
Esempio n. 22
0
void FreeGroup(struct ClcGroup *group)
{
	int i;
	if (group==NULL||IsBadCodePtr((FARPROC)group)) return;

	for(i=0;i<group->contactCount;i++) {
		if(group->contact && group->contact[i].type==CLCIT_GROUP) {
			FreeGroup(group->contact[i].group);
			mir_free(group->contact[i].group);      //**//
		}
	}
	if(group->allocedCount)
	{	
		if (group->contact->SubAllocated)
		{
			if (group->contact->subcontacts && !group->contact->isSubcontact) 
			{
				int i;
				for ( i = 0 ; i < group->contact->SubAllocated ; i++ )
				{
					Cache_DestroySmileyList(group->contact->subcontacts[i].plText);
					Cache_DestroySmileyList(group->contact->subcontacts[i].plSecondLineText);
					Cache_DestroySmileyList(group->contact->subcontacts[i].plThirdLineText);
          if (group->contact->subcontacts[i].szText) mir_free(group->contact->subcontacts[i].szText);
          if (group->contact->subcontacts[i].szSecondLineText) mir_free(group->contact->subcontacts[i].szSecondLineText);
          if (group->contact->subcontacts[i].szThirdLineText) mir_free(group->contact->subcontacts[i].szThirdLineText);
				}

				mir_free(group->contact->subcontacts);
			}
		}

		if(group->contact) 
		{
			Cache_DestroySmileyList(group->contact->plText);
			Cache_DestroySmileyList(group->contact->plSecondLineText);
			Cache_DestroySmileyList(group->contact->plThirdLineText);
      if (group->contact->szText) mir_free(group->contact->szText);
      if (group->contact->szSecondLineText) mir_free(group->contact->szSecondLineText);
      if (group->contact->szThirdLineText) mir_free(group->contact->szThirdLineText);
			mir_free(group->contact);
		}
	}
	group->allocedCount=0;
    //mir_free(group->contact);
	group->contact=NULL;
	group->contactCount=0;   
	ClearRowByIndexCache();
}
Esempio n. 23
0
QString CCrashStack::GetCallStack(PEXCEPTION_POINTERS pException)
{
        PBYTE	Module_Addr_1;
        char bufer[256]={0};
        QString sRet;

        typedef struct STACK
        {
                STACK *	Ebp;
                PBYTE	Ret_Addr;
                DWORD	Param[0];
        } STACK, * PSTACK;

        STACK	Stack = {0, 0};
        PSTACK	Ebp;

        if (pException)		//fake frame for exception address
        {
                Stack.Ebp = (PSTACK)pException->ContextRecord->Ebp;
                Stack.Ret_Addr = (PBYTE)pException->ExceptionRecord->ExceptionAddress;
                Ebp = &Stack;
        }
        else
        {
                Ebp = (PSTACK)&pException - 1;	//frame addr of Get_Call_Stack()

                // Skip frame of Get_Call_Stack().
                if (!IsBadReadPtr(Ebp, sizeof(PSTACK)))
                        Ebp = Ebp->Ebp;		//caller ebp
        }

        // Break trace on wrong stack frame.
        for (; !IsBadReadPtr(Ebp, sizeof(PSTACK)) && !IsBadCodePtr(FARPROC(Ebp->Ret_Addr));
                 Ebp = Ebp->Ebp)
        {
                // If module with Ebp->Ret_Addr found.
                memset(bufer,0, sizeof(0));
                sprintf(bufer, "\n%08X  ", (unsigned int)Ebp->Ret_Addr);
                sRet.append(bufer);

                QString moduleName = this->GetModuleByRetAddr(Ebp->Ret_Addr, Module_Addr_1) ;
                if (moduleName.length() > 0)
                {
                    sRet.append(moduleName);
                }
        }

        return sRet;
} //Get_Call_Stack
Esempio n. 24
0
BOOL He4HookDriverHide::GetNtProcAddresses()
{
  if (pRtlNtStatusToDosError == NULL)
  {
    HMODULE hNtDll = GetModuleHandle("ntdll.dll");
    if (hNtDll != NULL)
    {
      pRtlNtStatusToDosError = (RTLNTSTATUSTODOSERROR)GetProcAddress(hNtDll, "RtlNtStatusToDosError");
      if (IsBadCodePtr((FARPROC)pRtlNtStatusToDosError))
        pRtlNtStatusToDosError = NULL;
    }
  }

  return (BOOL)pRtlNtStatusToDosError;
}
Esempio n. 25
0
int mir_realloc_proxy(void *ptr,int size)
{
	if (IsBadCodePtr((FARPROC)ptr))
	{
		char buf[256];
		mir_snprintf(buf,sizeof(buf),"Bad code ptr in mir_realloc_proxy ptr: %x\r\n",ptr);
		//ASSERT("Bad code ptr");
		DebugBreak();
		TRACE(buf);
		return 0;
	}
	memoryManagerInterface.mmi_realloc(ptr,size);
	return 0;

}
Esempio n. 26
0
// Searches for [pOrigFunc] starting from [pImpFirstThunk], and replaces it with [pNewFunc] if found
int PatchFuncByPtr(PIMAGE_THUNK_DATA pImpFirstThunk, void* pOrigFunc, void* pNewFunc)
{
	PIMAGE_THUNK_DATA Thunk;

	// Verify that the newFunc is valid
	if(!pNewFunc || IsBadCodePtr((FARPROC)pNewFunc))	return 0;

	for(Thunk = pImpFirstThunk; Thunk->u1.Function; Thunk++)
	{
		if((DWORD*)Thunk->u1.Function == (DWORD*)pOrigFunc)	
		{
			return PatchFunc(Thunk, pNewFunc);
		}
	}
	// Function not found
	return 0;
}
Esempio n. 27
0
//-----------------------------------------------------------------------------
// Name: Show
// Object: create a modeless compare dialog box
// Parameters :
//     in  : HINSTANCE hInstance : application instance
//           HWND hWndDialog : main window dialog handle
//     out :
//     return : 
//-----------------------------------------------------------------------------
void CComShowMethodsAddress::Show(HINSTANCE hInstance,HWND hWndDialog)
{
    // assume HookComInfos.DynamicMessageBoxInDefaultStation has a meaning
    if (IsBadCodePtr((FARPROC)HookComInfos.DynamicMessageBoxInDefaultStation))
    {
#if (defined(UNICODE)||defined(_UNICODE))
        HookComInfos.DynamicMessageBoxInDefaultStation=(pfDynamicMessageBoxInDefaultStation)GetProcAddress(LoadLibrary(_T("User32.dll")),"MessageBoxW");
#else
        HookComInfos.DynamicMessageBoxInDefaultStation=(pfDynamicMessageBoxInDefaultStation)GetProcAddress(LoadLibrary(_T("User32.dll")),"MessageBoxA");
#endif
    }


    // show dialog
    UNREFERENCED_PARAMETER(hWndDialog);
    // create thread instead of using CreateDialogParam to don't have to handle keyboard event like TAB
    CloseHandle(CreateThread(NULL,0,CComShowMethodsAddress::ModelessDialogThread,hInstance,0,NULL));
}
Esempio n. 28
0
//-----------------------------------------------------------------------------
// Name: CallBacksThreadProc
// Object: thread launched on each events
// Parameters :
//     in  : PPROC_MON_THREAD_CALLBACK_PARAM Param : call back parameters
//     out : 
//     return : TRUE on success, FALSE on error
//-----------------------------------------------------------------------------
DWORD WINAPI CProcMonInterface::CallBacksThreadProc(PPROC_MON_THREAD_CALLBACK_PARAM Param)
{
    PROC_MON_CALLBACK pfunc;
    // switch process creation flag
    if (Param->ProcInfo.bCreate)
        pfunc=Param->pProcMonInterface->StartProcCallBack;
    else
        pfunc=Param->pProcMonInterface->StopProcCallBack;

    // check call back pointer
    if (!IsBadCodePtr((FARPROC)pfunc))
        // call the callback
        pfunc(Param->ProcInfo.hParentId,Param->ProcInfo.hProcessId);

    // free allocated memory
    HeapFree(GetProcessHeap(),0,Param);

    return 0;
}
Esempio n. 29
0
NDASVOL_LINKAGE
BOOL
NDASVOL_CALL
NdasEnumNdasScsiLocationsForVolume(
	IN HANDLE hVolume,
	NDASSCSILOCATIONENUMPROC EnumProc,
	LPVOID Context)
{
	if (IsBadCodePtr((FARPROC)EnumProc))
	{
		SetLastError(ERROR_INVALID_PARAMETER);
		return FALSE;
	}

	NDAS_LOCATION_CONTEXT_SHIM shimContext = { EnumProc, Context };

	return NdasEnumNdasLocationsForVolume(
		hVolume,
		NdasLocationCallbackShim,
		&shimContext);
}
Esempio n. 30
0
HRESULT _CreateInstance(const CLSID FAR* pclsid, LPCTSTR szDllName, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppv)
{
    HRESULT hres = ResultFromScode(REGDB_E_CLASSNOTREG);
    LPFNGETCLASSOBJECT lpfn = SHGetHandlerEntry(szDllName, c_szDllGetClassObject, NULL);
    if (lpfn)
    {
        IClassFactory *pCF;
        hres = lpfn(pclsid, &IID_IClassFactory, &pCF);
        if (SUCCEEDED(hres))
        {
            if (IsBadReadPtr(pCF, SIZEOF(pCF->lpVtbl))
                || IsBadReadPtr(pCF->lpVtbl, SIZEOF(*pCF->lpVtbl))
                || IsBadCodePtr(pCF->lpVtbl->CreateInstance))
            {
                DebugMsg(DM_ERROR, TEXT("sh ER - DllGetClassObject returned invalid object (%s)"), szDllName);
                Assert(0);
                hres = ResultFromScode(E_UNEXPECTED);
            }
            else
            {
                hres = pCF->lpVtbl->CreateInstance(pCF, pUnkOuter, riid, ppv);
                pCF->lpVtbl->Release(pCF);
            }
        }
        else
        {
            DebugMsg(DM_TRACE, TEXT("sh TR CoCreateInstance: GetClassObject failed (%s, %x)"), szDllName, hres);
        }
    }
    else
    {
        DWORD err = GetLastError();
        hres = HRESULT_FROM_WIN32(err);
        DebugMsg(DM_TRACE, TEXT("sh TR CoCreateInstance: SHGetHandlerEntry failed (%s, %x)"), szDllName, hres);
    }

    return hres;
}