Skip to content

CreateWindowExW Hook fails? #41

@ci70

Description

@ci70

Hi this hook fails when injected in Explorer.exe on Windows 8.1 x64. Maybe because of trampoline size?
To test compile and inject in to Explorer.exe using ProcessHacker x64.

library Hook64;

uses
  System.SysUtils,
  System.Classes,
  Winapi.Windows,
  DDetours;

type
  HINST = NativeUInt;
  HMENU = type UINT_PTR;

var
_CreateWindowExW: function(
  dwExStyle: DWORD;
  lpClassName: LPCWSTR;
  lpWindowName: LPCWSTR;
  dwStyle: DWORD;
  x: Integer;
  y: Integer;
  nWidth: Integer;
  nHeight: Integer;
  hWndParent: HWND;
  hMenu: HMENU;
  hInstance: HINST;
  lpParam: LPVOID
): HWND; WINAPI = nil;


function __CreateWindowExW(
  dwExStyle: DWORD;
  lpClassName: LPCWSTR;
  lpWindowName: LPCWSTR;
  dwStyle: DWORD;
  x: Integer;
  y: Integer;
  nWidth: Integer;
  nHeight: Integer;
  hWndParent: HWND;
  hMenu: HMENU;
  hInstance: HINST;
  lpParam: LPVOID
): HWND; WINAPI;

begin
  if (lpClassName = 'Worker Window') then
  WriteLn('Intercepted!');

  Result := _CreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
end;

begin
  AllocConsole;
  @_CreateWindowExW := InterceptCreate(@CreateWindowExW, @__CreateWindowExW);
end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions