views:

133

answers:

1

Hi,

I am working on a dll injection soft in c#, the injected dll is also in c# and i'am using pinvoke for certain system functions.

When using extTextOut i get the string scrambled and the lines get mixed together What am i doing wrong?

I hooked extTextOut using EasyHook from codeplex.com like this:

try
            {                
                CreateFileHook = LocalHook.Create(
                    LocalHook.GetProcAddress("gdi32.dll", "ExtTextOutW"),
                    new DExtTextOutW(ExtTextOutW_Hooked),
                   this);

                CreateFileHook.ThreadACL.SetExclusiveACL(new Int32[1]);

            }

and my extTextOut method is

[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, CallingConvention = CallingConvention.StdCall)]
        static extern bool ExtTextOutW(IntPtr hdc,
                                       int X,
                                       int Y,
                                       uint fuOptions,
                                       [In] ref RECT lprc,
                                       string lpString,
                                       uint cbCount,
                                       [In] IntPtr lpDx);

static bool ExtTextOutW_Hooked(
            IntPtr hdc,
            int X,
            int Y,
            uint fuOptions,
            [In] ref RECT lprc,
            string lpString,
            uint cbCount,
            [In] IntPtr lpDx)
        {


            try
            {
                DemoInjection This = (DemoInjection)HookRuntimeInfo.Callback;

                lock (This.Queue)
                {                    
                    This.Queue.Push(lpString);

                }
            }
            catch
            {
            }           

            return ExtTextOutW(
                 hdc,
                 X,
                 Y,
                 fuOptions,
                 ref lprc,
                 lpString,
                 cbCount,
                 lpDx
                  );

        }

And another question if i may. How can i constantly monitor a window which is out of focus or minimized(using this approach it does not work properly)

Thanks a lot!

A: 

I had the same problem. Do you have solutions already?

ssteo