How to fool window into thinking is has focus
- MiesterMan
- Posts: 543
- Joined: Tue Jul 06, 2010 9:15 pm
- Location: Between the Second and Third Circles of Hell
How to fool window into thinking is has focus
So I've been researching this and found an MSDN that might explain how to do this, but I was wondering if micromacro already has this functionality.
If Micromacro can send any windows message it might be possible to manipulate what the window thinks. If not I'd need to hook the dll function that tells the game if it has focus. Anyone know the straight up way how to do this either way using micromacro?
The MSDN info is here: http://msdn.microsoft.com/en-us/library ... spx#active
Some of the surrounding topics are related to this issue too.
If Micromacro can send any windows message it might be possible to manipulate what the window thinks. If not I'd need to hook the dll function that tells the game if it has focus. Anyone know the straight up way how to do this either way using micromacro?
The MSDN info is here: http://msdn.microsoft.com/en-us/library ... spx#active
Some of the surrounding topics are related to this issue too.
My RoM Bot toys:
- Object Viewer: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2619
Teleporter Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2605
Waypoint Finder: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2616
Mail Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2612
Equipment Swapper(TempFixed): http://www.solarstrike.net/phpBB3/viewt ... =27&t=2571
- MiesterMan
- Posts: 543
- Joined: Tue Jul 06, 2010 9:15 pm
- Location: Between the Second and Third Circles of Hell
Re: How to fool window into thinking is has focus
Digging deeper, it would seem I need to hook this functionhttp://msdn.microsoft.com/en-us/library ... s.85).aspx
My RoM Bot toys:
- Object Viewer: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2619
Teleporter Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2605
Waypoint Finder: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2616
Mail Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2612
Equipment Swapper(TempFixed): http://www.solarstrike.net/phpBB3/viewt ... =27&t=2571
- MiesterMan
- Posts: 543
- Joined: Tue Jul 06, 2010 9:15 pm
- Location: Between the Second and Third Circles of Hell
Re: How to fool window into thinking is has focus
Alright, with this short program I found the address of USER32.DLL in the game I'm working on:
And a list off offsets at http://www.autoitscript.com/forum/topic ... user32dll/
Edit: My mistake, I misread the chart for the info below this edit. The offset puts me in the ntdll.dll file though so I'm not sure where to go from here.
Code: Select all
local procId = findProcess("The Lord of the Rings Online*");
local Origin = getModuleAddress(procId, "User32.dll");
printf("0x%x",Origin);
Edit: My mistake, I misread the chart for the info below this edit. The offset puts me in the ntdll.dll file though so I'm not sure where to go from here.
My RoM Bot toys:
- Object Viewer: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2619
Teleporter Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2605
Waypoint Finder: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2616
Mail Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2612
Equipment Swapper(TempFixed): http://www.solarstrike.net/phpBB3/viewt ... =27&t=2571
- Administrator
- Site Admin
- Posts: 5329
- Joined: Sat Jan 05, 2008 4:21 pm
Re: How to fool window into thinking is has focus
Are you running a 64-bit OS? I'm just making a wild guess here, but you're probably actually getting mislead by 32-bit emulation.
If you're going to do some real injection, you might consider writing a DLL to inject. You should use GetProcAddress() to locate the function (IsWindowEnabled).
If you're going to do some real injection, you might consider writing a DLL to inject. You should use GetProcAddress() to locate the function (IsWindowEnabled).
- MiesterMan
- Posts: 543
- Joined: Tue Jul 06, 2010 9:15 pm
- Location: Between the Second and Third Circles of Hell
Re: How to fool window into thinking is has focus
GetProcAddress? That works? I mean, where is the label? I mean where is this proc label that MM uses to locate it?Administrator wrote:Are you running a 64-bit OS? I'm just making a wild guess here, but you're probably actually getting mislead by 32-bit emulation.
If you're going to do some real injection, you might consider writing a DLL to inject. You should use GetProcAddress() to locate the function (IsWindowEnabled).
My RoM Bot toys:
- Object Viewer: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2619
Teleporter Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2605
Waypoint Finder: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2616
Mail Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2612
Equipment Swapper(TempFixed): http://www.solarstrike.net/phpBB3/viewt ... =27&t=2571
- Administrator
- Site Admin
- Posts: 5329
- Joined: Sat Jan 05, 2008 4:21 pm
Re: How to fool window into thinking is has focus
You can't use it from MicroMacro. It needs to be called from within the process you want the information from. An injected DLL would suffice. When it comes to function hooking, I really recommend using injectable DLLs where possible as that allows more direct control over the process and easier/more advanced hooks without needing to learn assembly.
- MiesterMan
- Posts: 543
- Joined: Tue Jul 06, 2010 9:15 pm
- Location: Between the Second and Third Circles of Hell
Re: How to fool window into thinking is has focus
Ah, see that is the reason I was considering using an injected DLL but I was trying to avoid it since it meant sharing the bot would require someone to download the DLL.
Anyways, I know how to make a DLL and how to access functions in one, but I've no idea how I would inject to hook a function in a DLL already in a program. Any tutorials available for this?
Anyways, I know how to make a DLL and how to access functions in one, but I've no idea how I would inject to hook a function in a DLL already in a program. Any tutorials available for this?
My RoM Bot toys:
- Object Viewer: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2619
Teleporter Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2605
Waypoint Finder: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2616
Mail Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2612
Equipment Swapper(TempFixed): http://www.solarstrike.net/phpBB3/viewt ... =27&t=2571
- Administrator
- Site Admin
- Posts: 5329
- Joined: Sat Jan 05, 2008 4:21 pm
Re: How to fool window into thinking is has focus
I recommend Azorbix's detours to hook the functions. Makes it easy. GetProcAddress() is great for non-OO libraries (such as Winsock or OpenGL) that are linked in (doesn't mater if it is static or dynamic, so as long as you know the function name, use this). You can also just use the function address directly if you have to.
Oh, and make sure you compile your DLL as C; C++ will cause name-mangling which means it won't work.
Here's an example of hooking glBegin in OpenGL:
I've attached Azorbix's detours library.
Oh, and make sure you compile your DLL as C; C++ will cause name-mangling which means it won't work.
Here's an example of hooking glBegin in OpenGL:
Code: Select all
typedef void ( APIENTRY *glBegin_t )( GLenum );
glBegin_t pglBegin = NULL;
void APIENTRY Hooked_glBegin( GLenum mode )
{
// Add your own code here.
// Call original function
if(pglBegin)
(*pglBegin)(mode);
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{
switch(fdwReason)
{
HMODULE hOpenGL = GetModuleHandle("opengl32.dll");
case DLL_PROCESS_ATTACH:
pglBegin = (glBegin_t)DetourFunc( (LPBYTE)GetProcAddress(hOpenGL, "glBegin"),
(LPBYTE)&Hooked_glBegin,6);
break;
case DLL_PROCESS_DETACH:
// Unhook it here; not providing an example
break;
}
return TRUE;
}
- Attachments
-
- detours.zip
- (1.78 KiB) Downloaded 603 times
Who is online
Users browsing this forum: No registered users and 2 guests