Changeset 46083 in vbox for trunk/src/VBox/Runtime/common/dbg/dbgmodldr.cpp
- Timestamp:
- May 14, 2013 11:39:28 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/dbg/dbgmodldr.cpp
r46025 r46083 41 41 #include <iprt/string.h> 42 42 #include "internal/dbgmod.h" 43 #include "internal/ldr.h" 43 44 #include "internal/magics.h" 44 45 … … 54 55 /** The loader handle. */ 55 56 RTLDRMOD hLdrMod; 56 /** File handle for the image. */57 RTFILE hFile;58 57 } RTDBGMODLDR; 59 58 /** Pointer to instance data NM map reader. */ … … 80 79 return VERR_NO_MEMORY; 81 80 82 int rc = RTFileReadAt(pThis->hFile, off, pvMap, cb, NULL);81 int rc = rtLdrReadAt(pThis->hLdrMod, pvMap, off, cb); 83 82 if (RT_SUCCESS(rc)) 84 83 *ppvMap = pvMap; … … 134 133 pThis->hLdrMod = NIL_RTLDRMOD; 135 134 136 rc = RTFileClose(pThis->hFile); AssertRC(rc);137 pThis->hFile = NIL_RTFILE;138 139 135 RTMemFree(pThis); 140 136 … … 146 142 static DECLCALLBACK(int) rtDbgModLdr_TryOpen(PRTDBGMODINT pMod) 147 143 { 148 RT FILE hFile;149 int rc = RT FileOpen(&hFile, pMod->pszImgFile, RTFILE_O_READ | RTFILE_O_DENY_WRITE | RTFILE_O_OPEN);144 RTLDRMOD hLdrMod; 145 int rc = RTLdrOpen(pMod->pszImgFile, RTLDR_O_FOR_DEBUG, RTLDRARCH_WHATEVER, &hLdrMod); 150 146 if (RT_SUCCESS(rc)) 151 147 { 152 RTLDRMOD hLdrMod; 153 rc = RTLdrOpen(pMod->pszImgFile, RTLDR_O_FOR_DEBUG, RTLDRARCH_WHATEVER, &hLdrMod); 154 if (RT_SUCCESS(rc)) 155 { 156 PRTDBGMODLDR pThis = (PRTDBGMODLDR)RTMemAllocZ(sizeof(RTDBGMODLDR)); 157 if (pThis) 158 { 159 pThis->hLdrMod = hLdrMod; 160 pThis->hFile = hFile; 161 pMod->pvImgPriv = pThis; 162 return VINF_SUCCESS; 163 } 164 165 rc = VERR_NO_MEMORY; 148 rc = rtDbgModLdrOpenFromHandle(pMod, hLdrMod); 149 if (RT_FAILURE(rc)) 166 150 RTLdrClose(hLdrMod); 167 }168 169 RTFileClose(hFile);170 151 } 171 152 return rc; … … 191 172 }; 192 173 174 175 /** 176 * Open PE-image trick. 177 * 178 * @returns IPRT status code 179 * @param pDbgMod The debug module instance. 180 * @param hLdrMod The module to open a image debug backend for. 181 */ 182 DECLHIDDEN(int) rtDbgModLdrOpenFromHandle(PRTDBGMODINT pDbgMod, RTLDRMOD hLdrMod) 183 { 184 PRTDBGMODLDR pThis = (PRTDBGMODLDR)RTMemAllocZ(sizeof(RTDBGMODLDR)); 185 if (!pThis) 186 return VERR_NO_MEMORY; 187 188 pThis->hLdrMod = hLdrMod; 189 pDbgMod->pvImgPriv = pThis; 190 return VINF_SUCCESS; 191 } 192
Note:
See TracChangeset
for help on using the changeset viewer.