Example #1
0
const char *appSymbolName(address_t addr)
{
	static char	buf[256];

#if USE_DBGHELP
	if (appSymbolName(addr, ARRAY_ARG(buf)))
		return buf;
#endif

#if GET_EXTENDED_INFO
	HMODULE hModule = NULL;
	char moduleName[256];
	char *s;

	MEMORY_BASIC_INFORMATION mbi;
	if (!VirtualQuery((void*)addr, &mbi, sizeof(mbi)))
		goto simple;
	if (!(hModule = (HMODULE)mbi.AllocationBase))
		goto simple;
	if (!GetModuleFileName(hModule, ARRAY_ARG(moduleName)))
		goto simple;

//	if (s = strrchr(moduleName, '.'))	// cut extension
//		*s = 0;
	if (s = strrchr(moduleName, '\\'))
		strcpy(moduleName, s+1);		// remove "path\" part
	appSprintf(ARRAY_ARG(buf), "%s+0x%X", moduleName, (int)(addr - (size_t)hModule));
	return buf;
#endif // GET_EXTENDED_INFO

simple:
	appSprintf(ARRAY_ARG(buf), "%08X", addr);
	return buf;
}
Example #2
0
// Display the information in one exception frame, along with its scopetable
static void ShowSEHFrame(VC_EXCEPTION_REGISTRATION * pVCExcRec)
{
	// note: handler may be inside kernel, and it will not use VC_EXCEPTION_REGISTRATION structures!
	bool isCpp = pVCExcRec->handler == _except_handler3;
	printf("Frame: %08X  Handler: %s  Prev: %08X", pVCExcRec, appSymbolName((address_t)pVCExcRec->handler), pVCExcRec->prev);
	if (isCpp) printf(" Scopetable: %08X [%d]", pVCExcRec->scopetable, pVCExcRec->trylevel);
	printf("\n");
	if (!isCpp) return;

	scopetable_entry *pScopeTableEntry = pVCExcRec->scopetable;
	for (int i = 0; i <= pVCExcRec->trylevel; i++, pScopeTableEntry++)
	{
		char filter[256], handler[256];
		strcpy(filter, appSymbolName((address_t)pScopeTableEntry->lpfnFilter));
		strcpy(handler, appSymbolName((address_t)pScopeTableEntry->lpfnHandler));
		printf("    scopetable[%i] PrevTryLevel: %08X  filter: %s  __except: %s\n", i, pScopeTableEntry->previousTryLevel, filter, handler);
	}
}
Example #3
0
void appDumpStackTrace(const address_t* buffer, int depth)
{
	for (int i = 0; i < depth; i++)
	{
		if (!buffer[i]) break;
		const char *symbol = appSymbolName(buffer[i]);
		appPrintf("    %s\n", symbol);
	}
}
Example #4
0
void CCommandCompletion::RegisterWorker(CCmdCompletorWorker &worker)
{
	for (int i = 0; i < ARRAY_COUNT(workers); i++)
	{
		if (workers[i] == &worker) return;	// already registered
		if (!workers[i])
		{
			// register worker
			workers[i] = &worker;
			return;
		}
	}
	//!! check this:
	appWPrintf("Cannot register completor: \"%s\"\n", appSymbolName((address_t)&worker));
}
Example #5
0
int appSprintf(char *dest, int size, const char *fmt, ...)
{
	guardSlow(appSprintf);

	va_list	argptr;
	va_start(argptr, fmt);
	int len = vsnprintf(dest, size, fmt, argptr);
	va_end(argptr);
	if (len < 0 || len >= size - 1)
		appWPrintf("appSprintf: overflow of %d (called by \"%s\")\n", size, appSymbolName(GET_RETADDR(dest)));

	return len;

	unguardSlow;
}