Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 05-13-2004, 17:37
loman
 
Posts: n/a
Modules loaded by a exe

hi,
I would like to know how some programs such as LordPE displays dll loaded by an executable, what API are called? thanks in advance
Reply With Quote
  #2  
Old 05-13-2004, 18:53
Shub-Nigurrath's Avatar
Shub-Nigurrath Shub-Nigurrath is offline
VIP
 
Join Date: Mar 2004
Location: Obscure Kadath
Posts: 971
Rept. Given: 70
Rept. Rcvd 431 Times in 101 Posts
Thanks Given: 83
Thanks Rcvd at 405 Times in 127 Posts
Shub-Nigurrath Reputation: 400-499 Shub-Nigurrath Reputation: 400-499 Shub-Nigurrath Reputation: 400-499 Shub-Nigurrath Reputation: 400-499 Shub-Nigurrath Reputation: 400-499
look here, it's extremely simple

hxxp://www.codeguru.com/Cpp/W-P/system/processesmodules/article.php/c5729/

and also here

hxxp://www.codeguru.com/Cpp/W-P/system/processesmodules/article.php/c2873/
__________________
Ŝħůb-Ňìĝùŕřaŧħ ₪)
There are only 10 types of people in the world: Those who understand binary, and those who don't
http://www.accessroot.com
Reply With Quote
  #3  
Old 05-14-2004, 17:35
loman
 
Posts: n/a
thanks for the info man!
Reply With Quote
  #4  
Old 05-14-2004, 22:43
volodya
 
Posts: n/a
Sorry, but the method above is suxx. Too easy to fool. If you want to create sth really useful, you stick to NT+ architecture. Go search for "PEB_LDR_DATA". This is what you need.
Reply With Quote
  #5  
Old 05-14-2004, 22:50
Shub-Nigurrath's Avatar
Shub-Nigurrath Shub-Nigurrath is offline
VIP
 
Join Date: Mar 2004
Location: Obscure Kadath
Posts: 971
Rept. Given: 70
Rept. Rcvd 431 Times in 101 Posts
Thanks Given: 83
Thanks Rcvd at 405 Times in 127 Posts
Shub-Nigurrath Reputation: 400-499 Shub-Nigurrath Reputation: 400-499 Shub-Nigurrath Reputation: 400-499 Shub-Nigurrath Reputation: 400-499 Shub-Nigurrath Reputation: 400-499
humm..that undocumented things are supported through different OSs (XP,2003)?
It depends on which level you want to be sure of this..the infos obtained are almost the same, isn't it?
__________________
Ŝħůb-Ňìĝùŕřaŧħ ₪)
There are only 10 types of people in the world: Those who understand binary, and those who don't
http://www.accessroot.com
Reply With Quote
  #6  
Old 05-14-2004, 23:34
volodya
 
Posts: n/a
PEB is present starting from NT+.
The exact implementation of the structure is different. You can extract it from PDB-files using pdb-dump by de Quency.
Reply With Quote
  #7  
Old 05-18-2004, 18:32
disrupt0r
 
Posts: n/a
Quote:
Originally Posted by loman
hi,
I would like to know how some programs such as LordPE displays dll loaded by an executable, what API are called? thanks in advance
Code:
#include <tlhelp32.h> 

  DWORD currentProcessId = ::GetCurrentProcessId();
  HANDLE h = ::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, currentProcessId); 
  if (h != INVALID_HANDLE_VALUE) 
  {
    MODULEENTRY32 me32 = {0}; 
    me32.dwSize = sizeof MODULEENTRY32; 

    for (BOOL b = ::Module32First(h, &me32); b; b = ::Module32Next(h, &me32))
    { 
       // do something with me32
    }
    ::CloseHandle(h); 
  }
Reply With Quote
  #8  
Old 05-18-2004, 22:37
volodya
 
Posts: n/a
Lord PE is outdated. I personally, respect Yoda, but his really good piece of software has not been updated for many-many years. Thus, the method above is suxx. Use RtlQueryProcessDebugInformation instead.
Sth like:


QUERYDEBUGBUFFER *pModuleInfo; // modules information
DWORD dwNtStatus; // return code
// RtlQueryProcessDebugInformation
DWORD dwPID; // process PID
// get the memory for the buffer
DWORD *pRtlBuffer = RtlCreateQueryDebugBuffer(NULL, NULL);

if(!pRtlBuffer)
{
// Error!
}
// get the info about the modules
dwNtStatus = RtlQueryProcessDebugInformation((HANDLE *)dwPID, 0x01, pRtlBuffer);

if(!dwNtStatus)
{
pModuleInfo = (QUERYDEBUGBUFFER*)pRtlBuffer;

// enumerate the modules
for(int i = 0; i < pModuleInfo->dwNumNames; i++)
{
printf(��ImageBase: 0x%0.8Xl��, pModuleInfo[i]->ImageBase);
printf(��ImageSize: 0x%0.8Xl��, pModuleInfo[i]->ImageSize);
...
}
}
else if(dwNtStatus == DEBUG_ACCESS_DENIED)
{
// Error
}

// free the buffer
RtlDestroyQueryDebugBuffer(pModuleInfo);


Actually, we wrote much more information in
http://wasm.ru/article.php?article=packers2
but one has to know Russian to be able to understand sth...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Patch (IL Edit) of Assembles loaded from Resource cracki General Discussion 18 01-14-2024 00:26
Olly Crash when this simple app loaded... kunam General Discussion 6 10-10-2023 21:00
Working with multiple modules when reversing maktm General Discussion 2 04-19-2015 06:46
Runtime Error R6002 - Floating point not loaded MrGneissGuy's General Discussion 1 09-14-2009 03:08
Detection/Signature for Corba/Com/Dcom/Activex Modules nulli General Discussion 2 11-27-2005 18:41


All times are GMT +8. The time now is 21:15.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )