Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Solved: quickest way to find base of a dll

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
mStorm
Expert Cheater
Reputation: 0

Joined: 21 Feb 2009
Posts: 107

PostPosted: Sun Jul 19, 2009 3:10 am    Post subject: Solved: quickest way to find base of a dll Reply with quote

is using thlp32 and cycling through the modules the fastest way to find the base of a dll?

or is there another way that is much more simple?

(non injected).

*Solved: I just used looping through modules until I get the right name (using thlp32)


Last edited by mStorm on Tue Jul 21, 2009 12:00 pm; edited 1 time in total
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Jul 19, 2009 5:08 am    Post subject: Reply with quote

that's the best way that i'm aware of

here's a short source for it :
http://wj32.wordpress.com/2009/03/14/howto-get-the-command-line-of-a-process-in-unicode-or-ansi/

Code:
DWORD GetRemoteKernel32BaseAddress(int pid)
{
    HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);
    MODULEENTRY32 module;

    module.dwSize = sizeof(module);

    if (!Module32First(snapshot, &module))
        return 0;

    do
    {
        if (wcsicmp(module.szModule, _T("kernel32.dll")) == 0)
        {
            return (DWORD)module.modBaseAddr;
        }
    } while (Module32Next(snapshot, &module));

    return 0;
}
Back to top
View user's profile Send private message
Guy
Expert Cheater
Reputation: 0

Joined: 30 May 2009
Posts: 187

PostPosted: Sun Jul 19, 2009 10:14 am    Post subject: Reply with quote

That's the quickest way I know of as well; I made a sample using it to blacklist modules by name and entrypoint (Terrible, terrible idea; it was a piece of code I wrote intended for users to create hashes of the actual module, and check the names of modules that shouldn't change).

Regardless, here ya' go if you're interested: http://majii.wordpress.com/2009/07/17/whitelist-module-sample-quick-update/

_________________
Has anyone seen Hitler around..? If so, PM me!
Back to top
View user's profile Send private message
mStorm
Expert Cheater
Reputation: 0

Joined: 21 Feb 2009
Posts: 107

PostPosted: Mon Jul 20, 2009 5:17 am    Post subject: Reply with quote

Yea, i've put it to use. I was thinking there was a quicker way, but that is pretty quick.
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Mon Jul 20, 2009 5:18 pm    Post subject: Reply with quote

Of course there are "quicker" ways and definitly ways less intrusive..
but they are not "kosher"..but im guessing that CreateToolHelp32SnapShot Internals havent changed..(from XP to 7) and prolly wont. So open up kernel32 and analyze the functions to find the internals involved..also RtlQueryProcessDebugInformation works ..but for those fuckers that cry its "undocumented" they can shove it and there own heads up there ass..

there are others but I wont go over to them Wink

http://www.woodmann.com/forum/showthread.php?t=12883

regards BanMe

_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.
Back to top
View user's profile Send private message MSN Messenger
Guy
Expert Cheater
Reputation: 0

Joined: 30 May 2009
Posts: 187

PostPosted: Mon Jul 20, 2009 5:22 pm    Post subject: Reply with quote

BanMe wrote:
Of course there are "quicker" ways and definitly ways less intrusive..
but they are not "kosher"..but im guessing that CreateToolHelp32SnapShot Internals havent changed..(from XP to 7) and prolly wont. So open up kernel32 and analyze the functions to find the internals involved..also RtlQueryProcessDebugInformation works ..but for those fuckers that cry its "undocumented" they can shove it and there own heads up there ass..

there are others but I wont go over to them Wink

http://www.woodmann.com/forum/showthread.php?t=12883

regards BanMe


NtQuerySystemInformation Wink

But, there's a reason why you use the tool helper library; as you stated yourself, they're subject to change between kernel changes (Or, to be more broad, OS builds; XP, Vista, etc).

_________________
Has anyone seen Hitler around..? If so, PM me!
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Mon Jul 20, 2009 5:28 pm    Post subject: Reply with quote

they havent changed...look at them..
microsoft fucking lies through there teeth!

so lets go over why they wont change.. First the have to Modify Kernel32's
CreateToolHelp32SnapShot and Module/Thread/Process(32)/First and Next... thats a task in a of itself.. next they have to modify the Kernel to add another function that "attaches" to a process and queries info..they got enough of them..thirdly they have to also modify ntdll and add a new Syscall.. counting all this I highly doubt they will change..but yea, to each there own Wink also my "subsystem" Sin32 that im developing uses all these "undocumented" API's on 2k XP and (with slight) modifications) on Vista.. so hmm..they really changed "alot"..

regards BanMe

_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.
Back to top
View user's profile Send private message MSN Messenger
DoomsDay
Grandmaster Cheater
Reputation: 0

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Mon Jul 20, 2009 5:32 pm    Post subject: Reply with quote

^^^ On that subject, did you notice a difference in the PEB sturcutre?
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Mon Jul 20, 2009 5:37 pm    Post subject: Reply with quote

yes and I rewrote my Peb Dll Finder to function on everything from Nt ~ vista.. that was soooo hard.. lol

regards BanMe

_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.
Back to top
View user's profile Send private message MSN Messenger
Guy
Expert Cheater
Reputation: 0

Joined: 30 May 2009
Posts: 187

PostPosted: Mon Jul 20, 2009 6:41 pm    Post subject: Reply with quote

BanMe wrote:
they havent changed...look at them..
microsoft fucking lies through there teeth!

so lets go over why they wont change.. First the have to Modify Kernel32's
CreateToolHelp32SnapShot and Module/Thread/Process(32)/First and Next... thats a task in a of itself.. next they have to modify the Kernel to add another function that "attaches" to a process and queries info..they got enough of them..thirdly they have to also modify ntdll and add a new Syscall.. counting all this I highly doubt they will change..but yea, to each there own Wink also my "subsystem" Sin32 that im developing uses all these "undocumented" API's on 2k XP and (with slight) modifications) on Vista.. so hmm..they really changed "alot"..

regards BanMe


The point is, they do change:

BanMe wrote:
yes and I rewrote my Peb Dll Finder to function on everything from Nt ~ vista.. that was soooo hard.. lol

regards BanMe


There's an example with the changes made in the PEB structure; Microsoft can change anything they want, they have the time and resources, all they need is a reason on their part.

_________________
Has anyone seen Hitler around..? If so, PM me!
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Tue Jul 21, 2009 3:47 am    Post subject: Reply with quote

another reason not to use undocumented APIs. just the fact.. they ARE undocumented and often if they're not then they are documented poorly. admittedly there are places where more information on them can be found but for me it's not the effort compared to the convenience of msdn library
Back to top
View user's profile Send private message
DoomsDay
Grandmaster Cheater
Reputation: 0

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Tue Jul 21, 2009 6:48 am    Post subject: Reply with quote

Still, you must admit that using that would be faster (assuming that you made sure you're running on Windows XP SP3 ) Smile
Code:
XPSP3_GetModuleHandleW proc lpModName:DWORD
   LOCAL   t1:DWORD
   ASSUME   fs:nothing

   push   ebx
   mov      ebx,fs:[30h]
   mov      ebx,[ebx+0ch]
   lea      ebx,[ebx+0ch]
   mov      t1,ebx
   mov      ebx,[ebx]
   .repeat
      invoke   lstrcmpiW,lpModName,[ebx+30h]
      or      eax,eax
      jz      _found
      mov      ebx,[ebx]
   .until   (ebx ==   t1)
   xor      eax,eax
   jz      _end

   _found:
   mov      eax,[ebx+18h]

   _end:
   pop      ebx

   add      esp,4
   pop      ebp
   retn 4
XPSP3_GetModuleHandleW endp
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Tue Jul 21, 2009 7:56 am    Post subject: Reply with quote

yes.. but if you are gonna do little things like that then why not unroll all your loops to make it faster but bigger and there is a lot more things you can do. you could detect system and then write a separate code for each one. sometimes you have to compromise though. but i guess something small like this is personal preference
Back to top
View user's profile Send private message
DoomsDay
Grandmaster Cheater
Reputation: 0

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Tue Jul 21, 2009 8:28 am    Post subject: Reply with quote

Unrolling won't do well in this case (branch prediction - wise) Razz
Anyways, as you said - its all about personal preferences ^^
If anyone is interested, you might find this useful.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites