From c17419fc98cbe80ebd391f1f463c63dce2258ce2 Mon Sep 17 00:00:00 2001
From: "Mr. eXoDia"
basic calculations: See "Calculations" for more information.
-DLL exports - : Type 'GetProcAddress' and it will automatically be +
Module Data:
+Loaded Module Bases - - - - : If you want to access the loaded module base, -you can write: "[module]:0", "[module]:base", "[module]:imagebase" or -"[module]:header". You can also use '?' as a delimiter instead of ':'. This is -useful if the module contains an export called "imagebase" for -example.
-RVA/File Offset: -If you want to access a module RVA you can either write "[module]:0+[rva]" or -you can write "[module]:$[rva]". If you want -to convert a file offset to a VA you can use "[module]:#[offset]". When "[module]" is -an empty string (":0" for example), the module that is currently selected in the CPU will -be used.
-Module Entry Points : To access a module entry point you can write "[module]:entry", -"[module]:oep" or "[module]:ep". Notice that when there are exports with the -names "entry", - - "oep" or -"ep" the address of these will be returned instead. You can also use '?' as -a delimiter instead of ':'. This is useful if the module contains an export called "entry" -for example.
+used.labels/symbols: user-defined labels and symbols are a valid expressions.
Input for arguments can always be done in any of
diff --git a/x64_dbg_dbg/value.cpp b/x64_dbg_dbg/value.cpp
index ed5a1754..918d454f 100644
--- a/x64_dbg_dbg/value.cpp
+++ b/x64_dbg_dbg/value.cpp
@@ -1169,12 +1169,16 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
if(!value or !DbgIsDebugging())
return false;
//explicit API handling
- const char* apiname = strstr(name, ":"); //the ':' character cannot be in a path: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions
+ const char* apiname = strchr(name, ':'); //the ':' character cannot be in a path: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions
bool noexports = false;
- if(!apiname)
+ if(!apiname) //not found
{
- apiname = strstr(name, "?"); //the '?' character cannot be in a path either
- noexports = true;
+ apiname = strrchr(name, '.'); //kernel32.GetProcAddress support
+ if(!apiname) //not found
+ {
+ apiname = strchr(name, '?'); //the '?' character cannot be in a path either
+ noexports = true;
+ }
}
if(apiname)
{
@@ -1204,45 +1208,49 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
}
else
{
- wchar_t* szBaseName = wcschr(szModName, L'\\');
- if(szBaseName)
+ HMODULE mod = LoadLibraryExW(szModName, 0, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
+ if(!mod)
{
- szBaseName++;
- HMODULE mod = LoadLibraryExW(szModName, 0, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
- if(!mod)
+ if(!silent)
+ dprintf("unable to load library %s\n", szModName);
+ }
+ else
+ {
+ uint addr = noexports ? 0 : (uint)GetProcAddress(mod, apiname);
+ if(addr) //found exported function
+ addr = modbase + (addr - (uint)mod); //correct for loaded base
+ else //not found
{
- if(!silent)
- dprintf("unable to load library %s\n", szBaseName);
- }
- else
- {
- uint addr = noexports ? 0 : (uint)GetProcAddress(mod, apiname);
- if(addr) //found exported function
- addr = modbase + (addr - (uint)mod); //correct for loaded base
- else //not found
+ if(scmp(apiname, "base") or scmp(apiname, "imagebase") or scmp(apiname, "header")) //get loaded base
+ addr = modbase;
+ else if(scmp(apiname, "entry") or scmp(apiname, "oep") or scmp(apiname, "ep")) //get entry point
+ addr = modbase + GetPE32DataW(szModName, 0, UE_OEP);
+ else if(*apiname == '$') //RVA
{
- if(scmp(apiname, "base") or scmp(apiname, "imagebase") or scmp(apiname, "header")) //get loaded base
- addr = modbase;
- else if(scmp(apiname, "entry") or scmp(apiname, "oep") or scmp(apiname, "ep")) //get entry point
- addr = modbase + GetPE32DataW(szModName, 0, UE_OEP);
- else if(*apiname == '$') //RVA
+ uint rva;
+ if(valfromstring(apiname + 1, &rva))
+ addr = modbase + rva;
+ }
+ else if(*apiname == '#') //File Offset
+ {
+ uint offset;
+ if(valfromstring(apiname + 1, &offset))
+ addr = valfileoffsettova(modname, offset);
+ }
+ else
+ {
+ if(noexports) //get the exported functions with the '?' delimiter
{
- uint rva;
- if(valfromstring(apiname + 1, &rva))
- addr = modbase + rva;
- }
- else if(*apiname == '#') //File Offset
- {
- uint offset;
- if(valfromstring(apiname + 1, &offset))
- addr = valfileoffsettova(modname, offset);
+ addr = (uint)GetProcAddress(mod, apiname);
+ if(addr) //found exported function
+ addr = modbase + (addr - (uint)mod); //correct for loaded base
}
else
{
uint ordinal;
if(valfromstring(apiname, &ordinal))
{
- addr = noexports ? 0 : (uint)GetProcAddress(mod, (LPCSTR)(ordinal & 0xFFFF));
+ addr = (uint)GetProcAddress(mod, (LPCSTR)(ordinal & 0xFFFF));
if(addr) //found exported function
addr = modbase + (addr - (uint)mod); //correct for loaded base
else if(!ordinal) //support for getting the image base using