ntBldSymDb.cpp revision f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * IPRT - RTDirCreateUniqueNumbered, generic implementation.
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * Copyright (C) 2013 Oracle Corporation
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * available from http://www.virtualbox.org. This file is free software;
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * you can redistribute it and/or modify it under the terms of the GNU
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * General Public License (GPL) as published by the Free Software
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * The contents of this file may alternatively be used under the terms
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * of the Common Development and Distribution License Version 1.0
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * VirtualBox OSE distribution, in which case the provisions of the
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * CDDL are applicable instead of those of the GPL.
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * You may elect to license modified versions of this file under the
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * terms and conditions of either the GPL or the CDDL or both.
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync/*******************************************************************************
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync* Header Files *
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync*******************************************************************************/
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsyncstatic BOOL CALLBACK enumTypesCallback(PSYMBOL_INFO pSymInfo, ULONG cbSymbol, PVOID pvUser)
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync RTPrintf("pSymInfo=%p cbSymbol=%#x SizeOfStruct=%#x\n", pSymInfo, cbSymbol, pSymInfo->SizeOfStruct);
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync RTPrintf(" TypeIndex=%#x Reserved[0]=%#llx Reserved[1]=%#llx info=%#x\n",
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync pSymInfo->TypeIndex, pSymInfo->Reserved[0], pSymInfo->Reserved[1], pSymInfo->Index);
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync RTPrintf(" Size=%#x ModBase=%#llx Flags=%#x Value=%#llx Address=%#llx\n",
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync pSymInfo->Size, pSymInfo->ModBase, pSymInfo->Flags, pSymInfo->Value, pSymInfo->Address);
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync RTPrintf(" Register=%#x Scope=%#x Tag=%#x NameLen=%#x MaxNameLen=%#x Name=%s\n",
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync pSymInfo->Register, pSymInfo->Scope, pSymInfo->Tag, pSymInfo->NameLen, pSymInfo->MaxNameLen, pSymInfo->Name);
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * We need the size later on, so get that now and present proper IPRT error
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * info if the file is missing or inaccessible.
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync int rc = RTPathQueryInfo(pszPdb, &ObjInfo, RTFSOBJATTRADD_NOTHING);
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPathQueryInfo fail on '%s': %Rrc\n", pszPdb, rc);
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * Create a fake handle and open the PDB.
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync return RTMsgErrorExit(RTEXITCODE_FAILURE, "SymInitialied failed: %u\n", GetLastError());
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync uModAddr = SymLoadModuleEx(hFake, NULL /*hFile*/, pszPdb, NULL /*pszModuleName*/,
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync uModAddr, ObjInfo.cbObject, NULL /*pData*/, 0 /*fFlags*/);
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * Enumerate types.
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync if (SymEnumTypes(hFake, uModAddr, enumTypesCallback, NULL))
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "SymEnumTypes failed: %u\n", GetLastError());
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "SymCleanup failed: %u\n", GetLastError());
f43a0c088fd5cc014b52d34b0e7d23b9e5ca5858vboxsync * Parse options.