Skip to content

Commit ed5fbad

Browse files
committed
DBG: allow accessing the entry point of a module with "<module>:entry"
1 parent ce2f140 commit ed5fbad

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

help/Input.htm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@
6464
to convert a file offset to a VA you can use "[module]:#[offset]". When "[module]" is
6565
an empty string (":0" for example), the module that is currently selected in the CPU will
6666
be used.</P>
67+
<P class=rvps3><U>Module Entry Points</U>
68+
69+
: To
70+
access a module entry point you can write "[module]:entry", "[module]:oep" or "[module]:ep". Notice that when
71+
there are exports with the names "entry", "oep" or "ep" the address of these will be
72+
returned instead.</P>
6773
<P class=rvps3><U>labels/symbols</U>:
6874
user-defined labels and symbols&nbsp;are a valid expressions.</P>
6975
<P class=rvps3><STRONG>Input for arguments can always be done in any of

x64_dbg_dbg/value.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,8 +1213,10 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
12131213
uint addr = (uint)GetProcAddress(mod, apiname);
12141214
if(!addr) //not found
12151215
{
1216-
if(!_stricmp(apiname, "base") or !_stricmp(apiname, "imagebase") or !_stricmp(apiname, "header"))
1216+
if(scmp(apiname, "base") or scmp(apiname, "imagebase") or scmp(apiname, "header")) //get loaded base
12171217
addr = modbase;
1218+
else if(scmp(apiname, "entry") or scmp(apiname, "oep") or scmp(apiname, "ep")) //get entry point
1219+
addr = modbase + GetPE32DataW(szModName, 0, UE_OEP);
12181220
else if(*apiname == '$') //RVA
12191221
{
12201222
uint rva;
@@ -1233,7 +1235,7 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
12331235
if(valfromstring(apiname, &ordinal))
12341236
{
12351237
addr = (uint)GetProcAddress(mod, (LPCSTR)(ordinal & 0xFFFF));
1236-
if(!addr and !ordinal)
1238+
if(!addr and !ordinal) //support for getting the image base using <modname>:0
12371239
addr = modbase;
12381240
}
12391241
}

0 commit comments

Comments
 (0)