Skip to content

Commit 3199025

Browse files
committed
DBG: fixed a bug in valapifromstring (the correction for the loaded base in the debuggee was bad)
1 parent 50e3388 commit 3199025

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

x64_dbg_dbg/value.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,9 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
12171217
else
12181218
{
12191219
uint addr = noexports ? 0 : (uint)GetProcAddress(mod, apiname);
1220-
if(!addr) //not found
1220+
if(addr) //found exported function
1221+
addr = modbase + (addr - (uint)mod); //correct for loaded base
1222+
else //not found
12211223
{
12221224
if(scmp(apiname, "base") or scmp(apiname, "imagebase") or scmp(apiname, "header")) //get loaded base
12231225
addr = modbase;
@@ -1241,7 +1243,9 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
12411243
if(valfromstring(apiname, &ordinal))
12421244
{
12431245
addr = noexports ? 0 : (uint)GetProcAddress(mod, (LPCSTR)(ordinal & 0xFFFF));
1244-
if(!addr and !ordinal) //support for getting the image base using <modname>:0
1246+
if(addr) //found exported function
1247+
addr = modbase + (addr - (uint)mod); //correct for loaded base
1248+
else if(!ordinal) //support for getting the image base using <modname>:0
12451249
addr = modbase;
12461250
}
12471251
}
@@ -1253,12 +1257,7 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
12531257
*value_size = sizeof(uint);
12541258
if(hexonly)
12551259
*hexonly = true;
1256-
uint rva;
1257-
if(addr == modbase)
1258-
rva = 0;
1259-
else
1260-
rva = addr - (uint)mod;
1261-
*value = modbase + rva;
1260+
*value = addr;
12621261
return true;
12631262
}
12641263
}

0 commit comments

Comments
 (0)