How to fool window into thinking is has focus

Ask questions about cheating in any games you would like. Does not need to pertain to MicroMacro.
Post Reply
Message
Author
User avatar
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

#1 Post by MiesterMan » Sun Oct 13, 2013 11:01 pm

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.

User avatar
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

#2 Post by MiesterMan » Sun Oct 13, 2013 11:39 pm

Digging deeper, it would seem I need to hook this functionhttp://msdn.microsoft.com/en-us/library ... s.85).aspx

User avatar
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

#3 Post by MiesterMan » Mon Oct 14, 2013 12:45 am

Alright, with this short program I found the address of USER32.DLL in the game I'm working on:

Code: Select all

local procId = findProcess("The Lord of the Rings Online*");
local Origin = getModuleAddress(procId, "User32.dll");
printf("0x%x",Origin);
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.

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: How to fool window into thinking is has focus

#4 Post by Administrator » Mon Oct 14, 2013 2:37 am

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).

User avatar
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

#5 Post by MiesterMan » Mon Oct 14, 2013 9:47 pm

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).
GetProcAddress? That works? I mean, where is the label? I mean where is this proc label that MM uses to locate it?

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: How to fool window into thinking is has focus

#6 Post by Administrator » Mon Oct 14, 2013 10:21 pm

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.

User avatar
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

#7 Post by MiesterMan » Tue Oct 15, 2013 9:14 am

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?

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: How to fool window into thinking is has focus

#8 Post by Administrator » Tue Oct 15, 2013 3:44 pm

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:

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;

}
I've attached Azorbix's detours library.
Attachments
detours.zip
(1.78 KiB) Downloaded 325 times

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests