title: Hooking extTextOut problems
body: <p>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. </p>
  
  <p>When using extTextOut i get the string scrambled and the lines get mixed together
  What am i doing wrong?</p>
  
  <p>I hooked extTextOut using EasyHook from codeplex.com like this:</p>
  
  <pre><code>try
              {                
                  CreateFileHook = LocalHook.Create(
                      LocalHook.GetProcAddress("gdi32.dll", "ExtTextOutW"),
                      new DExtTextOutW(ExtTextOutW_Hooked),
                     this);
  
                  CreateFileHook.ThreadACL.SetExclusiveACL(new Int32[1]);
  
              }
  </code></pre>
  
  <p>and my extTextOut method is</p>
  
  <pre><code>[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
                    );
  
          }
  </code></pre>
  
  <p>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)</p>
  
  <p>Thanks a lot!</p>