void ShowUserStreams( PVOID pMiniDump, int streamNum ) 
{
	// Check parameters 

	if( pMiniDump == 0 ) 
	{
		_ASSERTE( !_T("Invalid parameter.") ); 
		return; 
	}


	// Show the contents of user data streams 

		// First stream 

	ULONG StreamID = cFirstStreamID + streamNum; 

	PMINIDUMP_DIRECTORY  pMiniDumpDir  = 0; 
	PVOID                pStream       = 0; 
	ULONG                StreamSize    = 0; 

	if( !MiniDumpReadDumpStream( pMiniDump, StreamID, &pMiniDumpDir, 
	                             &pStream, &StreamSize ) ) 
	{
		DWORD ErrCode = GetLastError(); 
		if( ErrCode != 0 ) // 0 -> no such stream in the dump 
			_tprintf( _T("Error: MiniDumpReadDumpStream failed. Error: %u \n"), ErrCode ); 
		else 
			_tprintf( _T("Stream (id %u) not found in the minidump.\n"), StreamID ); 
	}
	else 
	{
		// Show the contents 

		if( ( pStream == 0 ) || ( StreamSize == 0 ) ) 
		{
			_tprintf( _T("Invalid stream (id %u).\n"), StreamID ); 
		}
		else if( IsBadStringPtrA( (LPCSTR)pStream, StreamSize ) ) 
		{
			_tprintf( _T("Invalid stream data (id %u).\n"), StreamID ); 
		}
		else 
		{
			_tprintf( _T("%s\n"), pStream ); 
		}
	}

}
Exemplo n.º 2
0
BSUMDRET   __stdcall
    CreateCurrentProcessMiniDumpA ( MINIDUMP_TYPE        eType      ,
                                    char *               szFileName ,
                                    DWORD                dwThread   ,
                                    EXCEPTION_POINTERS * pExceptInfo )
{
	
    // Check the string parameter because I am paranoid.
    ASSERT ( FALSE == IsBadStringPtrA ( szFileName , MAX_PATH ) ) ;
    if ( TRUE == IsBadStringPtrA ( szFileName , MAX_PATH ) )
    {
        return ( eBAD_PARAM ) ;
    }

    // The return value.
    BSUMDRET eRetVal = eDUMP_SUCCEEDED ;

	

    // Allocate enough space to hold the converted string.
    int iLen = ( lstrlenA ( szFileName ) + 1 ) * sizeof ( wchar_t ) ;
    wchar_t * pWideFileName = (wchar_t*)
                               HeapAlloc ( GetProcessHeap ( )         ,
                                           HEAP_GENERATE_EXCEPTIONS |
                                             HEAP_ZERO_MEMORY         ,
                                           iLen                       );

    int iRet = MultiByteToWideChar ( CP_ACP          ,
                                     MB_PRECOMPOSED  ,
                                     szFileName      ,
                                     -1              ,
                                     pWideFileName   ,
                                     iLen             ) ;
    ASSERT ( iRet != 0 ) ;
    if ( iRet != 0 )
    {
        // The conversion worked, call the wide function.
        eRetVal = CreateCurrentProcessMiniDumpW ( eType         ,
                                                  pWideFileName ,
                                                  dwThread      ,
                                                  pExceptInfo    ) ;
    }
    else
    {
        eRetVal = eBAD_PARAM ;
    }

    if ( NULL != pWideFileName )
    {
        HeapFree ( GetProcessHeap ( ) , 0 , pWideFileName ) ;
    }

    return ( eRetVal ) ;
}
Exemplo n.º 3
0
/**************************************************************************
 *              AddMRUStringA [COMCTL32.153]
 *
 * See AddMRUStringW.
 */
INT WINAPI AddMRUStringA(HANDLE hList, LPCSTR lpszString)
{
    DWORD len;
    LPWSTR stringW;
    INT ret;

    TRACE("(%p,%s)\n", hList, debugstr_a(lpszString));

    if (!hList)
        return -1;

    if (IsBadStringPtrA(lpszString, -1))
    {
        SetLastError(ERROR_INVALID_PARAMETER);
	return 0;
    }

    len = MultiByteToWideChar(CP_ACP, 0, lpszString, -1, NULL, 0) * sizeof(WCHAR);
    stringW = Alloc(len);
    if (!stringW)
        return -1;

    MultiByteToWideChar(CP_ACP, 0, lpszString, -1, stringW, len/sizeof(WCHAR));
    ret = AddMRUData(hList, stringW, len);
    Free(stringW);
    return ret;
}
Exemplo n.º 4
0
NDASVOL_LINKAGE
HRESULT
NDASVOL_CALL
NdasIsNdasPathA(
	IN LPCSTR FilePath)
{
	if (IsBadStringPtrA(FilePath, UINT_PTR(-1)))
	{
		XTLTRACE2(NdasVolTrace, TRACE_LEVEL_ERROR,
			"Invalid path, path=%hs\n", FilePath); 
		return E_INVALIDARG;
	}

	XTLTRACE2(NdasVolTrace, 4, "NdasIsNdasPathA(%hs)\n", FilePath);

	int nChars = MultiByteToWideChar(CP_ACP, 0, FilePath, -1, NULL, 0);
	++nChars; // additional terminating NULL char
	XTL::AutoProcessHeapPtr<WCHAR> wszFilePath = reinterpret_cast<LPWSTR>(
		::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, nChars * sizeof(WCHAR)));
	if (wszFilePath.IsInvalid())
	{
		return E_OUTOFMEMORY;
	}

	nChars = MultiByteToWideChar(CP_ACP, 0, FilePath, -1, wszFilePath, nChars);

	XTLASSERT(nChars > 0);

	return NdasIsNdasPathW(wszFilePath);
}
Exemplo n.º 5
0
WriteMiniDumpResult __stdcall WriteMiniDumpA(MINIDUMP_TYPE eType, char* szFileName, DWORD dwThread, EXCEPTION_POINTERS* pExceptInfo)
{
    // Check the string parameter because I am paranoid.
    if (IsBadStringPtrA(szFileName, MAX_PATH) == TRUE)
    {
        return WriteMiniDumpResult::BadParameter;
    }

    // The return value.
    WriteMiniDumpResult eRetVal = WriteMiniDumpResult::DumpSucceeded;

    // Allocate enough space to hold the converted string.
    int iLen = (lstrlenA(szFileName) + 1) * sizeof (wchar_t);
    wchar_t * pWideFileName = (wchar_t*)HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY, iLen);

    int iRet = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szFileName, -1, pWideFileName, iLen);
    if (iRet != 0)
    {
        // The conversion worked, call the wide function.
        eRetVal = WriteMiniDumpW(eType, pWideFileName, dwThread, pExceptInfo);
    }
    else
    {
        eRetVal = WriteMiniDumpResult::BadParameter;
    }
    if (pWideFileName != NULL)
    {
        HeapFree(GetProcessHeap(), 0, pWideFileName);
    }
    return eRetVal;
}
Exemplo n.º 6
0
/////////////////////////////////////////////////////////////////////////////
// GetStringCopyAmountA
//
// delete after use.
/////////////////////////////////////////////////////////////////////////////
char*
	GetStringCopyAmountA(
	const char*	SourceString,
	size_t		Amount)
{
	char* StringCopy = NULL;

	if (NULL != SourceString)
	{
		BOOL BadString	= IsBadStringPtrA(SourceString,(UINT_PTR)-1);

		if (FALSE == BadString)
		{
			size_t	SourceStringLength = (strlen(SourceString) + 1);

			StringCopy = new char[Amount+1];

			if (NULL != StringCopy)
			{
				strncpy_s(	StringCopy,
					Amount+1,
					SourceString,
					Amount);
			}
		}
	}

	return StringCopy;
}
Exemplo n.º 7
0
/*! ユーザー定義関数のエラーメッセージの作成

	stdProc, stdIntFunc, stdStrFunc がエラーコードを返した場合、PPAから呼び出される。
	異常終了/不正引数時のエラーメッセージを独自に指定する。
	@author Moca
	@param Err_CD IN  0以外各コールバック関数が設定した値
			 1以上 FuncID + 1
			 0     PPAのエラー
			-1以下 その他ユーザ定義エラー
	@param Err_Mes IN エラーメッセージ

	@date 2003.06.01 Moca
*/
void __stdcall CPPA::stdError( int Err_CD, const char* Err_Mes )
{
	if( false != m_CurInstance->m_bError ){
		return;
	}
	m_CurInstance->m_bError = true; // 関数内で関数を呼ぶ場合等、2回表示されるのを防ぐ

	TCHAR szMes[2048]; // 2048あれば足りるかと
	const TCHAR* pszErr;
	pszErr = szMes;
	if( 0 < Err_CD ){
		int i, FuncID;
		FuncID = Err_CD - 1;
		char szFuncDec[1024];
		szFuncDec[0] = '\0';
		for( i = 0; CSMacroMgr::m_MacroFuncInfoCommandArr[i].m_nFuncID != -1; i++ ){
			if( CSMacroMgr::m_MacroFuncInfoCommandArr[i].m_nFuncID == FuncID ){
				GetDeclarations( CSMacroMgr::m_MacroFuncInfoCommandArr[i], szFuncDec );
				break;
			}
		}
		if( CSMacroMgr::m_MacroFuncInfoArr[i].m_nFuncID != -1 ){
			for( i = 0; CSMacroMgr::m_MacroFuncInfoArr[i].m_nFuncID != -1; i++ ){
				if( CSMacroMgr::m_MacroFuncInfoArr[i].m_nFuncID == FuncID ){
					GetDeclarations( CSMacroMgr::m_MacroFuncInfoArr[i], szFuncDec );
					break;
				}
			}
		}
		if( szFuncDec[0] != '\0' ){
			auto_sprintf( szMes, LS(STR_ERR_DLGPPA2), szFuncDec );
		}else{
			auto_sprintf( szMes, LS(STR_ERR_DLGPPA3), FuncID );
		}
	}else{
		//	2007.07.26 genta : ネスト実行した場合にPPAが不正なポインタを渡す可能性を考慮.
		//	実際には不正なエラーは全てPPA.DLL内部でトラップされるようだが念のため.
		if( IsBadStringPtrA( Err_Mes, 256 )){
			pszErr = LS(STR_ERR_DLGPPA6);
		}else{
			switch( Err_CD ){
			case 0:
				if( '\0' == Err_Mes[0] ){
					pszErr = LS(STR_ERR_DLGPPA4);
				}else{
					pszErr = to_tchar(Err_Mes);
				}
				break;
			default:
				auto_sprintf( szMes, LS(STR_ERR_DLGPPA5), Err_CD, to_tchar(Err_Mes) );
			}
		}
	}
	if( 0 == m_CurInstance->m_cMemDebug.GetStringLength() ){
		MYMESSAGEBOX( m_CurInstance->m_pcEditView->GetHwnd(), MB_OK, LS(STR_ERR_DLGPPA7), _T("%ts"), pszErr );
	}
	else{
		MYMESSAGEBOX( m_CurInstance->m_pcEditView->GetHwnd(), MB_OK, LS(STR_ERR_DLGPPA7), _T("%ts\n%hs"), pszErr, m_CurInstance->m_cMemDebug.GetStringPtr() );
	}
}
Exemplo n.º 8
0
static PyObject *
z_get(void *ptr, Py_ssize_t size)
{
    /* XXX What about invalid pointers ??? */
    if (*(void **)ptr) {
#if defined(MS_WIN32) && !defined(_WIN32_WCE)
        if (IsBadStringPtrA(*(char **)ptr, -1)) {
            PyErr_Format(PyExc_ValueError,
                         "invalid string pointer %p",
                         *(char **)ptr);
            return NULL;
        }
#endif
        return PyString_FromString(*(char **)ptr);
    } else {
        Py_INCREF(Py_None);
        return Py_None;
    }
}
Exemplo n.º 9
0
/**************************************************************************
 *                  CreateMRUListLazyA [COMCTL32.157]
 *
 * Creates a most-recently-used list.
 *
 * PARAMS
 *     lpcml    [I] ptr to CREATEMRULIST structure.
 *     dwParam2 [I] Unknown
 *     dwParam3 [I] Unknown
 *     dwParam4 [I] Unknown
 *
 * RETURNS
 *     Handle to MRU list.
 */
HANDLE WINAPI CreateMRUListLazyA (const MRUINFOA *lpcml, DWORD dwParam2,
                                  DWORD dwParam3, DWORD dwParam4)
{
    LPWINEMRULIST mp;
    DWORD len;

    /* Native does not check for a NULL lpcml */

    if (!lpcml->hKey || IsBadStringPtrA(lpcml->lpszSubKey, -1))
	return 0;

    mp = Alloc(sizeof(WINEMRULIST));
    memcpy(&mp->extview, lpcml, sizeof(MRUINFOA));
    len = MultiByteToWideChar(CP_ACP, 0, lpcml->lpszSubKey, -1, NULL, 0);
    mp->extview.lpszSubKey = Alloc(len * sizeof(WCHAR));
    MultiByteToWideChar(CP_ACP, 0, lpcml->lpszSubKey, -1,
			mp->extview.lpszSubKey, len);
    mp->isUnicode = FALSE;
    return create_mru_list(mp);
}
Exemplo n.º 10
0
/**************************************************************************
 *                  CreateMRUListLazyA [COMCTL32.157]
 *
 * Creates a most-recently-used list.
 *
 * PARAMS
 *     lpcml    [I] ptr to CREATEMRULIST structure.
 *     dwParam2 [I] Unknown
 *     dwParam3 [I] Unknown
 *     dwParam4 [I] Unknown
 *
 * RETURNS
 *     Handle to MRU list.
 */
HANDLE WINAPI CreateMRUListLazyA (LPCREATEMRULISTA lpcml, DWORD dwParam2,
                                  DWORD dwParam3, DWORD dwParam4)
{
    LPWINEMRULIST mp;
    DWORD len;

    /* Native does not check for a NULL lpcml */

    if (lpcml->cbSize != sizeof(CREATEMRULISTA) || !lpcml->hKey ||
        IsBadStringPtrA(lpcml->lpszSubKey, -1))
	return 0;

    mp = Alloc(sizeof(WINEMRULIST));
    memcpy(&mp->extview, lpcml, sizeof(CREATEMRULISTW));
    len = MultiByteToWideChar(CP_ACP, 0, lpcml->lpszSubKey, -1, NULL, 0);
    mp->extview.lpszSubKey = Alloc(len * sizeof(WCHAR));
    MultiByteToWideChar(CP_ACP, 0, lpcml->lpszSubKey, -1,
			(LPWSTR)mp->extview.lpszSubKey, len);
    mp->isUnicode = FALSE;
    return CreateMRUListLazy_common(mp);
}
Exemplo n.º 11
0
char*
	GetStringCopyA(
	const char*	SourceString)
{
	char* StringCopy = NULL;

	if (NULL != SourceString)
	{
		BOOL BadString	= IsBadStringPtrA(SourceString,(UINT_PTR)-1);

		if (FALSE == BadString)
		{
			size_t	SourceStringLength = strlen(SourceString) + 1;

			StringCopy = new char[SourceStringLength];

			if (NULL != StringCopy)
			{
				strcpy_s(StringCopy, SourceStringLength, SourceString);
			}
		}
	}
	return StringCopy;
}
Exemplo n.º 12
0
static LRESULT CALLBACK ModernSkinButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	ModernSkinButtonCtrl* bct = (msg != WM_NCCREATE) ? (ModernSkinButtonCtrl *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA) : nullptr;
	if (bct) {
		if (bct->HandleService && IsBadStringPtrA(bct->HandleService, 255))
			bct->HandleService = nullptr;
		else if (bct->HandleService && ServiceExists(bct->HandleService)) {
			HandleServiceParams MSG = {};
			MSG.hwnd = hwndDlg;
			MSG.msg = msg;
			MSG.wParam = wParam;
			MSG.lParam = lParam;
			int t = CallService(bct->HandleService, (WPARAM)&MSG, 0);
			if (MSG.handled) return t;
		}
	}

	switch (msg) {
	case WM_NCCREATE:
		SetWindowLongPtr(hwndDlg, GWL_STYLE, GetWindowLongPtr(hwndDlg, GWL_STYLE) | BS_OWNERDRAW);
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
		if (((CREATESTRUCT *)lParam)->lpszName) SetWindowText(hwndDlg, ((CREATESTRUCT *)lParam)->lpszName);
		return TRUE;

	case WM_DESTROY:
		if (bct == nullptr)
			break;

		if (hwndToolTips) {
			mir_cslock lck(csTips);
			TOOLINFO ti = { 0 };
			ti.cbSize = sizeof(ti);
			ti.uFlags = TTF_IDISHWND;
			ti.hwnd = bct->hwnd;
			ti.uId = (UINT_PTR)bct->hwnd;
			if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti))
				SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti);

			if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM)&ti) == 0) {
				DestroyWindow(hwndToolTips);
				hwndToolTips = nullptr;
			}
		}
		mir_free(bct->ID);
		mir_free(bct->CommandService);
		mir_free(bct->StateService);
		mir_free(bct->HandleService);
		mir_free(bct->Hint);
		mir_free(bct->ValueDBSection);
		mir_free(bct->ValueTypeDef);
		mir_free(bct);
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
		break;	// DONT! fall thru

	case WM_SETCURSOR:
		{
			HCURSOR hCurs1 = LoadCursor(nullptr, IDC_ARROW);
			if (hCurs1) SetCursor(hCurs1);
			if (bct) SetToolTip(hwndDlg, bct->Hint);
		}
		return 1;

	case WM_PRINT:
		if (IsWindowVisible(hwndDlg))
			ModernSkinButtonPaintWorker(hwndDlg, (HDC)wParam);
		break;

	case WM_PAINT:
		if (IsWindowVisible(hwndDlg) && !g_CluiData.fLayered) {
			PAINTSTRUCT ps = {};
			BeginPaint(hwndDlg, &ps);
			ModernSkinButtonPaintWorker(hwndDlg, (HDC)ps.hdc);
			EndPaint(hwndDlg, &ps);
		}
		return DefWindowProc(hwndDlg, msg, wParam, lParam);

	case WM_CAPTURECHANGED:
		if (bct) {
			bct->hover = 0;
			bct->down = 0;
			ModernSkinButtonPaintWorker(bct->hwnd, nullptr);
		}
		break;

	case WM_MOUSEMOVE:
		if (bct) {
			if (!bct->hover) {
				SetCapture(bct->hwnd);
				bct->hover = 1;
				ModernSkinButtonPaintWorker(bct->hwnd, nullptr);
			}
			else {
				POINT t = UNPACK_POINT(lParam);
				ClientToScreen(bct->hwnd, &t);
				if (WindowFromPoint(t) != bct->hwnd)
					ReleaseCapture();
			}
		}
		return 0;

	case WM_LBUTTONDOWN:
		if (bct) {
			bct->down = 1;
			SetForegroundWindow(GetParent(bct->hwnd));
			ModernSkinButtonPaintWorker(bct->hwnd, nullptr);
			if (bct->CommandService && IsBadStringPtrA(bct->CommandService, 255))
				bct->CommandService = nullptr;
			if (bct->fCallOnPress) {
				if (bct->CommandService) {
					if (!_CallServiceStrParams(bct->CommandService, nullptr) && (bct->ValueDBSection && bct->ValueTypeDef))
						ModernSkinButtonToggleDBValue(bct->ValueDBSection, bct->ValueTypeDef);
				}
				bct->down = 0;

				ModernSkinButtonPaintWorker(bct->hwnd, nullptr);
			}
		}
		return 0;

	case WM_LBUTTONUP:
		if (bct && bct->down) {
			ReleaseCapture();
			bct->hover = 0;
			bct->down = 0;
			ModernSkinButtonPaintWorker(bct->hwnd, nullptr);
			if (bct->CommandService && IsBadStringPtrA(bct->CommandService, 255))
				bct->CommandService = nullptr;
			if (bct->CommandService)
				if (_CallServiceStrParams(bct->CommandService, nullptr)) {
				}
				else if (bct->ValueDBSection && bct->ValueTypeDef)
					ModernSkinButtonToggleDBValue(bct->ValueDBSection, bct->ValueTypeDef);
		}
	}
	return DefWindowProc(hwndDlg, msg, wParam, lParam);
}
mBOOL DLLINTERNAL is_gamedll(const char *filename) {
	HANDLE hFile;
	HANDLE hMap;
	void * mapview;
	IMAGE_NT_HEADERS * ntheaders;
	IMAGE_SECTION_HEADER * sections;
	int num_sects;
	IMAGE_EXPORT_DIRECTORY * exports;

	int has_GiveFnptrsToDll = 0;
	int has_GetEntityAPI2 = 0;
	int has_GetEntityAPI = 0;

	// Try open file for read
	hFile = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if(is_invalid_handle(hFile)) {
		META_DEBUG(3, ("is_gamedll(%s): CreateFile() failed.", filename));
		return(mFALSE);
	}
	
	//
	hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
	if(is_invalid_handle(hMap)) {
		META_DEBUG(3, ("is_gamedll(%s): CreateFileMapping() failed.", filename));
		CloseHandle(hFile);
		return(mFALSE);
	}
	
	//
	mapview = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0);
	if(!mapview) {
		META_DEBUG(3, ("is_gamedll(%s): MapViewOfFile() failed.", filename));
		CloseHandle(hMap);
		CloseHandle(hFile);
		return(mFALSE);
	}
	
	ntheaders = get_ntheaders(mapview);
	if(!ntheaders) {
		META_DEBUG(3, ("is_gamedll(%s): get_ntheaders() failed.", filename));
		UnmapViewOfFile(mapview);
		CloseHandle(hMap);
		CloseHandle(hFile);
		return(mFALSE);
	}
	
	//Sections for va_to_mapaddr function
	sections = IMAGE_FIRST_SECTION(ntheaders);
	num_sects = ntheaders->FileHeader.NumberOfSections;
	if(IsBadReadPtr(sections, num_sects * sizeof(IMAGE_SECTION_HEADER))) {
		META_DEBUG(3, ("is_gamedll(%s): IMAGE_FIRST_SECTION() failed.", filename));
		UnmapViewOfFile(mapview);
		CloseHandle(hMap);
		CloseHandle(hFile);
		return(mFALSE);
	}
	
	//
	exports = get_export_table(mapview, ntheaders, sections, num_sects);
	if(!exports) {
		META_DEBUG(3, ("is_gamedll(%s): get_export_table() failed.", filename));
		UnmapViewOfFile(mapview);
		CloseHandle(hMap);
		CloseHandle(hFile);
		return(mFALSE);
	}
	
	//
	unsigned long * names = (unsigned long *)va_to_mapaddr(mapview, sections, num_sects, exports->AddressOfNames);
	if(IsBadReadPtr(names, exports->NumberOfNames * sizeof(unsigned long))) {
		META_DEBUG(3, ("is_gamedll(%s): Pointer to exported function names is invalid.", filename));
		UnmapViewOfFile(mapview);
		CloseHandle(hMap);
		CloseHandle(hFile);
		return(mFALSE);
	}
	
	for(unsigned int i = 0; i < exports->NumberOfNames; i++) {
		//get function name with valid address
		char * funcname = (char *)va_to_mapaddr(mapview, sections, num_sects, names[i]);
		if(IsBadStringPtrA(funcname, 128))
			continue;
		
		// Check
		// Fast check for 'G' first
		if(funcname[0] == 'G') {
			// Collect export information
			if(!has_GiveFnptrsToDll)
				has_GiveFnptrsToDll = strmatch(funcname, "GiveFnptrsToDll");
			if(!has_GetEntityAPI2)
				has_GetEntityAPI2   = strmatch(funcname, "GetEntityAPI2");
	  		if(!has_GetEntityAPI)
	  			has_GetEntityAPI    = strmatch(funcname, "GetEntityAPI");
	  	}
		// Check if metamod plugin
		else if(funcname[0] == 'M') {
			if(strmatch(funcname, "Meta_Init") || 
			   strmatch(funcname, "Meta_Query") || 
			   strmatch(funcname, "Meta_Attach") || 
			   strmatch(funcname, "Meta_Detach")) {
				// Metamod plugin.. is not gamedll
				META_DEBUG(5, ("is_gamedll(%s): Detected Metamod plugin, library exports [%s].", filename, funcname));
		   		
				UnmapViewOfFile(mapview);
				CloseHandle(hMap);
				CloseHandle(hFile);
				
				return(mFALSE);
			}
		}
	}
	
	UnmapViewOfFile(mapview);
	CloseHandle(hMap);
	CloseHandle(hFile);
	
	// Check if gamedll
	if(has_GiveFnptrsToDll && (has_GetEntityAPI2 || has_GetEntityAPI)) {
		// This is gamedll!
		META_DEBUG(5, ("is_gamedll(%s): Detected GameDLL.", filename));

		return(mTRUE);
	} else {
		META_DEBUG(5, ("is_gamedll(%s): Library isn't GameDLL.", filename));
		
		return(mFALSE);
	}
}
Exemplo n.º 14
0
            SnapCurrentProcessMiniDumpA ( MINIDUMP_TYPE eType      ,
                                          const char *  szDumpName  )
                                          
{
    // Where the registers coming into this function are stored.
    CONTEXT stInitialCtx ;
    // Where the final registers are stored.
    CONTEXT stFinalCtx ;
    // The return value.
    BSUMDRET    eRet ;
    // Boolean return value local.
    BOOL        bRetVal ;

    // Do the prolog.
    SNAPPROLOG ( stInitialCtx ) ;

    eRet = eDUMP_SUCCEEDED ;

    // Check the string parameter.
    ASSERT ( FALSE == IsBadStringPtrA ( szDumpName , MAX_PATH ) ) ;
    if ( TRUE == IsBadStringPtrA ( szDumpName , MAX_PATH ) )
    {
        eRet = eBAD_PARAM ;
    }
    if ( eDUMP_SUCCEEDED == eRet )
    {
        // Zero out the final context structure.
        ZeroMemory ( &stFinalCtx , sizeof ( CONTEXT ) ) ;
            
        // Inicate I want everything in the context.
        stFinalCtx.ContextFlags = CONTEXT_FULL                 |
                                    CONTEXT_CONTROL            |
                                    CONTEXT_DEBUG_REGISTERS    |
                                    CONTEXT_EXTENDED_REGISTERS |
                                    CONTEXT_FLOATING_POINT       ;
                                       
        // Get all the groovy context registers and such for this
        // thread.
        bRetVal = GetThreadContext ( GetCurrentThread ( ) ,&stFinalCtx);
        ASSERT ( TRUE == bRetVal ) ;
        if ( TRUE == bRetVal )
        {
            COPYKEYCONTEXTREGISTERS ( stFinalCtx , stInitialCtx ) ;

            // Get the return address and hunt down the call instruction
            // that got us into this function.  All the rest of the
            // registers are set up before the call so I'll ensure the
            // instruction pointer is set that way too.
            UINT_PTR dwRetAddr = (UINT_PTR)_ReturnAddress ( ) ;
            bRetVal = CalculateBeginningOfCallInstruction ( dwRetAddr );
            ASSERT ( TRUE == bRetVal ) ;
            if ( TRUE == bRetVal )
            {
                // Set the instruction pointer to the beginning of the
                // call instruction.
                stFinalCtx.Eip = (DWORD)dwRetAddr ;
                
                // Create the wide version of the filename.
                int iLen = ( lstrlenA ( szDumpName ) + 1 ) *
                                            sizeof ( wchar_t ) ;
                wchar_t * pWideFileName = (wchar_t*)
                                HeapAlloc ( GetProcessHeap ( )        ,
                                            HEAP_GENERATE_EXCEPTIONS |
                                               HEAP_ZERO_MEMORY       ,
                                            iLen                      );
                ASSERT ( NULL != pWideFileName ) ;
                
                int iRet = BSUAnsi2Wide ( szDumpName    ,
                                        pWideFileName ,
                                        iLen           ) ;
                ASSERT ( iRet > 0 ) ;
                if ( iRet > 0 )
                {
                    // Call the common function that does the actual
                    // write.
                    eRet =
                        CommonSnapCurrentProcessMiniDump (eType        ,
                                                          pWideFileName,
                                                          &stFinalCtx );
                    if ( NULL != pWideFileName )
                    {
                        HeapFree ( GetProcessHeap ( ) ,
                                   0                  ,
                                   pWideFileName       ) ;
                    }
                                                          
                }
                else
                {
                    eRet = eBAD_PARAM ;
                }
            }
            else
            {
                eRet = eGETTHREADCONTEXT_FAILED ;
            }
        }
    }
    // Do the epilog.
    SNAPEPILOG ( eRet ) ;
}
Exemplo n.º 15
0
Arquivo: util.c Projeto: GYGit/reactos
/**************************************************************************
 *  IsBadBoundedStringPtr@8 (MAPI32.71)
 *
 * Determine if a string pointer is valid.
 *
 * PARAMS
 *  lpszStr [I] String to check
 *  ulLen   [I] Maximum length of lpszStr
 *
 * RETURNS
 *  TRUE, if lpszStr is invalid or longer than ulLen,
 *  FALSE, otherwise.
 */
BOOL WINAPI IsBadBoundedStringPtr(LPCSTR lpszStr, ULONG ulLen)
{
    if (!lpszStr || IsBadStringPtrA(lpszStr, -1) || strlen(lpszStr) >= ulLen)
        return TRUE;
    return FALSE;
}