| View previous topic :: View next topic |
| Author |
Message |
mStorm Expert Cheater
Reputation: 0
Joined: 21 Feb 2009 Posts: 107
|
Posted: Sun Jul 19, 2009 3:10 am Post subject: Solved: quickest way to find base of a dll |
|
|
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 |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jul 19, 2009 5:08 am Post subject: |
|
|
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 |
|
 |
Guy Expert Cheater
Reputation: 0
Joined: 30 May 2009 Posts: 187
|
Posted: Sun Jul 19, 2009 10:14 am Post subject: |
|
|
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 |
|
 |
mStorm Expert Cheater
Reputation: 0
Joined: 21 Feb 2009 Posts: 107
|
Posted: Mon Jul 20, 2009 5:17 am Post subject: |
|
|
| Yea, i've put it to use. I was thinking there was a quicker way, but that is pretty quick.
|
|
| Back to top |
|
 |
BanMe Master Cheater
Reputation: 0
Joined: 29 Nov 2005 Posts: 375 Location: Farmington NH, USA
|
|
| Back to top |
|
 |
Guy Expert Cheater
Reputation: 0
Joined: 30 May 2009 Posts: 187
|
|
| Back to top |
|
 |
BanMe Master Cheater
Reputation: 0
Joined: 29 Nov 2005 Posts: 375 Location: Farmington NH, USA
|
|
| Back to top |
|
 |
DoomsDay Grandmaster Cheater
Reputation: 0
Joined: 06 Jan 2007 Posts: 768 Location: %HomePath%
|
Posted: Mon Jul 20, 2009 5:32 pm Post subject: |
|
|
| ^^^ On that subject, did you notice a difference in the PEB sturcutre?
|
|
| Back to top |
|
 |
BanMe Master Cheater
Reputation: 0
Joined: 29 Nov 2005 Posts: 375 Location: Farmington NH, USA
|
Posted: Mon Jul 20, 2009 5:37 pm Post subject: |
|
|
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 |
|
 |
Guy Expert Cheater
Reputation: 0
Joined: 30 May 2009 Posts: 187
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Tue Jul 21, 2009 3:47 am Post subject: |
|
|
| 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 |
|
 |
DoomsDay Grandmaster Cheater
Reputation: 0
Joined: 06 Jan 2007 Posts: 768 Location: %HomePath%
|
Posted: Tue Jul 21, 2009 6:48 am Post subject: |
|
|
Still, you must admit that using that would be faster (assuming that you made sure you're running on Windows XP SP3 )
| 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 |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Tue Jul 21, 2009 7:56 am Post subject: |
|
|
| 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 |
|
 |
DoomsDay Grandmaster Cheater
Reputation: 0
Joined: 06 Jan 2007 Posts: 768 Location: %HomePath%
|
Posted: Tue Jul 21, 2009 8:28 am Post subject: |
|
|
Unrolling won't do well in this case (branch prediction - wise)
Anyways, as you said - its all about personal preferences ^^
If anyone is interested, you might find this useful.
|
|
| Back to top |
|
 |
|