ReactOS  r75919
wpickclick.c File Reference
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <windows.h>
#include "hook.h"
Include dependency graph for wpickclick.c:

Go to the source code of this file.

Macros

#define APP_NAME   "wpickclick.exe"
 
#define __PRINTF_ATTR(fmt, args)
 

Functions

static BOOL (WINAPI *pInstallHooks)(HMODULE hdll)
 
static void (WINAPI *pRemoveHooks)()
 
static action_t *WINAPIpGetAction ()
 
static int init_debug ()
 
static void cxlog (const char *format,...) __PRINTF_ATTR(1
 
static HINSTANCE load_hook_dll ()
 
charcleanup (char *str)
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 

Variables

static int debug_on =0
 

Macro Definition Documentation

#define __PRINTF_ATTR (   fmt,
  args 
)

Definition at line 49 of file wpickclick.c.

#define APP_NAME   "wpickclick.exe"

Definition at line 34 of file wpickclick.c.

Referenced by WinMain().

Function Documentation

static BOOL ( WINAPI pInstallHooks)
static
char* cleanup ( char str)

Definition at line 99 of file wpickclick.c.

Referenced by _Dispatch_type_(), _Success_(), _test_shape_ok(), action_RegDeleteTreeA(), ActivateThemeFile(), AddAceToDesktop(), AddAceToWindowStation(), AddDriverToList(), Addhost(), AddKnownDriverToList(), AddProvider(), AppendStringToMultiSZ(), BrsFolder_NewFolder(), build_directshowfilters_tree(), build_zonemap_from_reg(), BUTTON_GetIdealSize(), CcpMapData(), check_cursor_data(), check_wellknown_name(), CheckForDeviceDesc(), CheckSectionValid(), ChooseGinaUI(), ClassAddDevice(), ClientSideInstallW(), CLRRuntimeHost_ExecuteInDefaultAppDomain(), co_IntDrawCaret(), co_UserCreateWindowEx(), CoMarshalInterface(), COMDLG32_FR_DoFindReplace(), CommandDir(), convert_vertex_buffer(), create_monodata(), create_new_eventlog(), create_test_file(), create_view_window2_hook(), CreateClassDeviceObject(), CreateGreenFdo(), CreateProfile(), CCabinet::CreateSimpleCabinet(), CreateTempDir(), CreateWindowStationAndDesktops(), CryptSIPRetrieveSubjectGuid(), D3DPreprocess(), d3drm_viewport2_Init(), D3DTests(), d3dx9_mesh_ConvertAdjacencyToPointReps(), d3dx9_mesh_ConvertPointRepsToAdjacency(), d3dx9_mesh_GenerateAdjacency(), d3dx9_mesh_OptimizeInplace(), D3DXCheckTextureRequirements(), D3DXLoadMeshFromXInMemory(), D3DXLoadMeshHierarchyFromXInMemory(), D3DXLoadSkinMeshFromXof(), D3DXRenderToEnvMap_BeginCube(), D3DXRenderToEnvMap_Face(), D3DXRenderToSurface_BeginScene(), D3DXSaveSurfaceToFileInMemory(), D3DXWeldVertices(), DdQueryDirectDrawObject(), DeleteFileToRecycleBinA(), DeleteFileToRecycleBinW(), Deletehost(), DEVENUM_RegisterLegacyAmFilters(), devinst_RegDeleteTreeW(), DevInstallW(), DIB_CreateDIBSection(), DisplayApplet(), DisplayArpEntries(), DisplayClassInstaller(), DoAutoLogon(), DrawThemeText(), DriverEntry(), EDIT_WM_NCCreate(), EmitREBytecode(), EmptyRecycleBinA(), EmptyRecycleBinW(), EnableUserModePnpManager(), EngCopyBits(), EnumDisplayMonitors(), EnumerateDevices(), EnumerateRecycleBinA(), EnumerateRecycleBinW(), EnumPwrSchemes(), ext2_initialize_sb(), ext2_mkdir(), ext4_ext_insert_extent(), ext4_ext_split(), FileEncryptionStatusA(), fill_display_information_d3d(), fill_display_information_fallback(), fill_file_description(), fill_filter_container(), fill_filter_data_information(), FindAdapterKey(), FindProvTypesRegVals(), GdipGetVisibleClipBounds(), GdipIsVisibleClipEmpty(), GdipIsVisiblePoint(), GdipIsVisibleRect(), GetBusInterface(), GetDeletedFileDetailsA(), GetDeletedFileDetailsW(), GetFunctionPointer(), GetServiceDescription(), GetVersionInformationFromInfFile(), GreenQueryBusRelations(), HandleLogon(), HlinkClone(), HTMLLocation_get_href(), i8042ConnectMouseInterrupt(), i8042KbdInternalDeviceControl(), i8042MouInternalDeviceControl(), i8042SendHookWorkItem(), IDirectXFileImpl_RegisterTemplates(), IEGetNameAndFlagsEx(), ImageList_Create(), ImageList_DrawIndirect(), InitializeSAS(), InitShellServices(), InsertAudioDevice(), InstallDevice(), InstallDevInst(), InstallHinfSectionW(), InstallInfSection(), InstallNetDevice(), InstallOneService(), IntDeleteRecursive(), IntDrawState(), Internal_CreatePalette(), Internal_CreateSurface(), IntGdiRealizePalette(), IntGrayString(), IntRectangle(), IntSetDIBits(), IntSynthesizeBitmap(), IntSynthesizeDib(), IoGetDeviceInterfaces(), IopDetectResourceConflict(), IopEnumerateDetectedDevices(), IopGetParentIdPrefix(), IopOpenInterfaceKey(), IopQueryRemoveChildDevices(), IopQueryRemoveDeviceRelations(), IopTranslateDeviceResources(), IoRequestDeviceEject(), IsAcpiComputer(), IsConsoleBoot(), IsConsoleShell(), IsLiveCD(), KdbCommand_Gdi_entry(), KMix_AddDevice(), KmtCloseService(), KmtCreateAndStartService(), KmtCreateService(), KmtDeleteService(), KmtRegisterIrpHandler(), KmtRegisterMessageHandler(), KmtStartService(), KmtStopService(), KmtUnregisterIrpHandler(), KmtUnregisterMessageHandler(), KmtUserCallbackThread(), KopDispatchCreate(), KsMergeAutomationTables(), ListTests(), LISTVIEW_EndEditLabelT(), load_mesh_container(), LoadGina(), LoadUserProfileA(), LoadUserProfileW(), main(), mpg123_replace_reader_handle(), mru_RegDeleteTreeA(), myRegDeleteTreeA(), myRegDeleteTreeW(), NdisOpenFile(), NdrpCompleteAsyncClientCall(), NetClassInstaller(), NLS_EnumCalendarInfo(), NSP_GetHostByNameHeapAllocW(), NtGdiCreateDIBBrush(), NtGdiCreateDIBitmapInternal(), NtGdiExtFloodFill(), NtGdiExtTextOutW(), NtGdiMaskBlt(), NtGdiStretchDIBitsInternal(), NtUserActivateKeyboardLayout(), NtUserChangeClipboardChain(), NtUserConvertMemHandle(), NtUserCountClipboardFormats(), NtUserCreateLocalMemHandle(), NtUserCreateWindowEx(), NtUserEnumDisplayMonitors(), NtUserGetClipboardData(), NtUserGetClipboardFormatName(), NtUserGetClipboardOwner(), NtUserGetClipboardSequenceNumber(), NtUserGetClipboardViewer(), NtUserGetIconSize(), NtUserGetKeyboardLayoutName(), NtUserGetKeyNameText(), NtUserGetMonitorInfo(), NtUserGetMouseMovePointsEx(), NtUserGetOpenClipboardWindow(), NtUserGetPriorityClipboardFormat(), NtUserIsClipboardFormatAvailable(), NtUserLoadKeyboardLayoutEx(), NtUserMonitorFromRect(), NtUserMonitorFromWindow(), NtUserRegisterHotKey(), NtUserSendInput(), NtUserSetClipboardViewer(), NtUserUnregisterHotKey(), CDefView::OnContextMenu(), CDefView::OnExplorerCommand(), OpenHardwareProfileKey(), OpenRegistryHandlesFromSymbolicLink(), CDefView::OpenSelectedItems(), package_RegDeleteTreeW(), CAddressEditBox::ParseNow(), PARSER_GetInfClassW(), PATH_add_outline(), PB_Paint(), PcAddAdapterDevice(), PcCreateItemDispatch(), PcCreatePinDispatch(), PcCreateSubdeviceDescriptor(), PciIdeXSetBusData(), PerfDataGetCommandLine(), PerformInternalLookup(), PerformLookup(), PNP_ReportLogOn(), PnpRootCreateDevice(), PnpRootQueryDeviceRelations(), PopulateCustomPathCombo(), POWRPROF_GetUserPowerPolicy(), preprocess_shader(), profile_items_callback(), RCreateServiceA(), read_bitmaps(), ReadGlobalPwrPolicy(), RecycleBin5_Constructor(), RecycleBin5_Create(), RecycleBin5_RecycleBin5_DeleteFile(), RegDeleteTreeW(), RegisterConnection(), RegLoadMUIStringA(), RegLoadMUIStringW(), RegReadString(), RenderHDROP(), ReportGreenPdo(), RSAENH_CPVerifySignature(), run_test(), RunTest(), SaveCustomPath(), ScmAssignNewTag(), ScreenAddDevice(), ScreenSaverThreadMain(), SearchCHM_File(), SearchForLegacyDrivers(), sendmail_extended_mapi(), SermouseAddDevice(), service_main(), SetDefaultLanguage(), SETUP_CreateDevicesList(), SETUP_CreateDevicesListFromEnumerator(), SETUP_CreateInterfaceList(), SETUP_GetClassIconInfo(), SETUP_GetIconIndex(), SETUPAPI_GetCurrentHwProfile(), SetupCopyOEMInfA(), SetupCopyOEMInfW(), SETUPDI_OpenDrvKey(), SetupDiChangeState(), SetupDiCreateDeviceInfoListExW(), SetupDiCreateDevRegKeyW(), SetupDiGetActualSectionToInstallExA(), SetupDiGetClassDescriptionExA(), SetupDiGetClassDevPropertySheetsW(), SetupDiGetClassDevsExW(), SetupDiGetClassImageListExW(), SetupDiGetINFClassW(), SetupDiInstallClassExW(), SetupDiInstallDevice(), SetupDiInstallDeviceInterfaces(), SetupDiInstallDriverFiles(), SetupDiLoadClassIcon(), SetupDiOpenDeviceInfoW(), SetupDiRegisterCoDeviceInstallers(), SetupGetInfFileListW(), SetupIsActive(), SHFileOperationA(), SHFileOperationW(), SHGetFolderPathAndSubDirA(), SnapWindow(), START_TEST(), StartScreenSaver(), SysAudio_AddDevice(), SystemProcessTest(), test_classesroot_enum(), test_CoGetPSClsid(), test_conf_complex_array(), test_copyto(), test_copyto_iidexclusions_storage(), test_copyto_iidexclusions_stream(), test_copyto_snbexclusions(), test_CreateRemoteThread(), Test_CreateService(), test_CryptCATAdminAddRemoveCatalog(), test_Device(), test_dot_parsing(), test_DrawIcon(), test_DrawIconEx(), test_DrawState(), test_DxDiag_DisplayDevices(), test_DxDiag_SoundCaptureDevices(), test_DxDiag_SoundDevices(), test_enum_provider_types(), test_enum_value(), test_EnumChildContainerNames(), test_EnumPropNames(), test_FileSecurity(), test_FindFirstFileExA(), test_font_height_scaling(), test_GetChildContainer(), test_GetCursorFrameInfo(), test_gethostbyname(), test_GetPlayerAddress(), test_GetProp(), test_getstring_no_extra(), test_GetZoneAt(), test_ImageList_DrawIndirect(), test_info(), test_ip_pktinfo(), test_junction_points(), test_LocalizedNames(), test_LockFile(), Test_LockUnlockServiceDatabase(), Test_LockUnlockServiceDatabaseWithServiceStart(), test_patch_registration(), test_persiststreaminit(), test_profile_items(), test_queryconfig2(), Test_QueryLockStatusA(), Test_QueryLockStatusW(), Test_QueryServiceConfig2A(), Test_QueryServiceConfig2W(), test_readwrite(), test_reg_query_value(), test_root_children(), test_SavingImages(), test_secure_connection(), test_SetZoneAttributes(), test_ShellItemCompare(), test_ShortcutFolder(), test_simple_patch(), test_start_stop(), test_system_tables(), test_TransmitFile(), test_TxGetNaturalSize(), test_viewport_clear2(), Test_WSAIoctl_GetInterfaceList(), test_xmldoc(), test_xmlelem_collection(), TestMyEventProvider(), TRACKBAR_Refresh(), UpdateDriverForPlugAndPlayDevicesW(), UrlApplySchemeA(), USBHUB_FdoStartDevice(), User32CreateWindowEx(), UserCloseClipboard(), UserDrawCaption(), UserEmptyClipboard(), UserEnumClipboardFormats(), UserLoadKbdFile(), UserMonitorFromRect(), UserOpenClipboard(), UserSetClipboardData(), WinMain(), WSHIoctl_GetInterfaceList(), and XCOPY_DoCopy().

100 {
101  char* s;
102 
103  while (*str==' ' || *str=='\t' || *str=='\r' || *str=='\n')
104  str++;
105  s=strchr(str,'\n');
106  if (!s)
107  s=str+strlen(str)-1;
108  while (s>str && (*s==' ' || *s=='\t' || *s=='\r' || *s=='\n'))
109  s--;
110  *(s+1)='\0';
111  return str;
112 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const WCHAR * str
GLdouble s
Definition: gl.h:2039
char * strchr(const char *String, int ch)
Definition: utclib.c:501
static void static void cxlog ( const char format,
  ... 
)
static

Definition at line 61 of file wpickclick.c.

Referenced by WinMain().

62 {
64 
65  if (debug_on)
66  {
67  va_start(valist, format);
68  vfprintf(stderr, format, valist);
69  va_end(valist);
70  }
71 }
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static int debug_on
Definition: wpickclick.c:51
#define va_start(ap, A)
Definition: acmsvcex.h:91
FILE * stderr
static __ms_va_list valist
Definition: printf.c:59
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
static int init_debug ( )
static

Definition at line 52 of file wpickclick.c.

Referenced by WinMain().

53 {
54  char* str=getenv("CXTEST_DEBUG");
55  if (str && strstr(str, "+hook"))
56  debug_on=1;
57  return debug_on;
58 }
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
const WCHAR * str
static int debug_on
Definition: wpickclick.c:51
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
static HINSTANCE load_hook_dll ( )
static

Definition at line 73 of file wpickclick.c.

Referenced by WinMain().

74 {
75  HINSTANCE hinstDll;
76  char dllpath[MAX_PATH];
77  char* p;
78 
79  hinstDll=LoadLibrary("hook.dll");
80  if (hinstDll != NULL)
81  return hinstDll;
82 
83  if (!GetModuleFileName(NULL,dllpath,sizeof(dllpath)))
84  return NULL;
85 
86  p=strrchr(dllpath,'\\');
87  if (!p)
88  return NULL;
89  *p='\0';
90  p=strrchr(dllpath,'\\');
91  if (!p)
92  return NULL;
93  *p='\0';
94  strcat(dllpath,"\\hookdll\\hook.dll");
95  hinstDll=LoadLibrary(dllpath);
96  return hinstDll;
97 }
#define LoadLibrary
Definition: winbase.h:3624
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
smooth NULL
Definition: ftsmooth.c:513
#define MAX_PATH
Definition: compat.h:26
#define GetModuleFileName
Definition: winbase.h:3593
HANDLE HINSTANCE
Definition: typedefs.h:76
GLfloat GLfloat p
Definition: glext.h:8902
static action_t* WINAPI* pGetAction ( )
static

Referenced by WinMain().

static void ( WINAPI pRemoveHooks)
static
int WINAPI WinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPSTR  lpCmdLine,
int  nCmdShow 
)

Definition at line 114 of file wpickclick.c.

116 {
117  HINSTANCE hDll;
118  action_t* action;
119 
120  init_debug();
121 
122  /* Our scripts expect Unix-style line ends */
123  _setmode(1,_O_BINARY);
124  _setmode(2,_O_BINARY);
125 
126  if (strstr(lpCmdLine,"--help"))
127  {
128  fprintf(stderr,"%s - Utility to print coordinates, component, window title, component class and window class name of a click\n", APP_NAME);
129  fprintf(stderr,"----------------------------------------------\n");
130  fprintf(stderr,"Usage: %s\n",APP_NAME);
131  fprintf(stderr,"The options are as follows:\n");
132  fprintf(stderr,"After starting you can\n");
133  fprintf(stderr,"select where to click. If we properly track the click, it will be reported\n");
134  fprintf(stderr,"in the following format:\n");
135  fprintf(stderr," button-name x y component_name window_name component_class_name window_class_name\n");
136  fprintf(stderr,"Note that x and y can be negative; this typically happens if you click within the\n");
137  fprintf(stderr,"window manager decorations of a given window.\n");
138  fprintf(stderr,"On success, %s returns 0, non zero on some failure\n",APP_NAME);
139  exit(0);
140  };
141 
142  /* Load the hook library */
143  hDll = load_hook_dll();
144  if (!hDll)
145  {
146  fprintf(stderr, "Error: Unable to load 'hook.dll'\n");
147  printf("failed\n");
148  return 1;
149  }
150 
151  pInstallHooks=(void*)GetProcAddress(hDll, "InstallHooks");
152  pRemoveHooks=(void*)GetProcAddress(hDll, "RemoveHooks");
153  pGetAction=(void*)GetProcAddress(hDll, "GetAction");
154  pFreeAction=(void*)GetProcAddress(hDll, "FreeAction");
155  if (!pInstallHooks || !pRemoveHooks || !pGetAction)
156  {
157  fprintf(stderr, "Error: Unable to get the hook.dll functions (%ld)\n",
158  GetLastError());
159  printf("failed\n");
160  return 1;
161  }
162 
163  if (!pInstallHooks(hDll))
164  {
165  fprintf(stderr, "Error: Unable to install the hooks (%ld)\n",
166  GetLastError());
167  printf("failed\n");
168  return 1;
169  }
170 
171  fprintf(stderr, "Ready for capture...\n");
172  action=pGetAction();
173  if (!action)
174  {
175  fprintf(stderr, "Error: GetAction() failed\n");
176  printf("failed\n");
177  return 1;
178  }
179 
180  switch (action->action)
181  {
182  case ACTION_FAILED:
183  printf("failed\n");
184  break;
185  case ACTION_NONE:
186  printf("none\n");
187  break;
188  case ACTION_FIND:
189  printf("find\n");
190  break;
191  case ACTION_BUTTON1:
192  case ACTION_BUTTON2:
193  case ACTION_BUTTON3:
194  printf("button%d %ld %ld\n", action->action-ACTION_BUTTON1+1,
195  action->x, action->y);
196  break;
197  default:
198  fprintf(stderr, "Error: Unknown action %d\n",action->action);
199  printf("%d\n", action->action);
200  break;
201  }
202  printf("%s\n", action->window_class);
203  printf("%s\n", action->window_title);
204  printf("%ld\n", action->control_id);
205  printf("%s\n", action->control_class);
206  printf("%s\n", cleanup(action->control_caption));
207 
208  cxlog("\n%s: action=%d x=%ld y=%ld\n", __FILE__, action->action,
209  action->x, action->y);
210  cxlog("window_class='%s'\n", action->window_class);
211  cxlog("window_title='%s'\n", action->window_title);
212  cxlog("control_id=%ld\n", action->control_id);
213  cxlog("control_class='%s'\n", action->control_class);
214  cxlog("control_caption='%s'\n", action->control_caption);
215 
216  pFreeAction(action);
217  pRemoveHooks();
218  return 0;
219 }
#define _setmode(fd, mode)
Definition: cat.c:21
#define ACTION_NONE
Definition: main.c:548
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
static int init_debug()
Definition: wpickclick.c:52
static void cxlog(const char *format,...) __PRINTF_ATTR(1
Definition: wpickclick.c:61
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static HINSTANCE load_hook_dll()
Definition: wpickclick.c:73
HANDLE HINSTANCE
Definition: typedefs.h:76
#define _O_BINARY
Definition: cabinet.h:59
#define exit(n)
Definition: config.h:202
const WCHAR * action
Definition: action.c:7683
FILE * stderr
char * cleanup(char *str)
Definition: wpickclick.c:99
#define GetProcAddress(x, y)
Definition: compat.h:410
static action_t *WINAPI * pGetAction()
#define APP_NAME
Definition: wpickclick.c:34
#define printf
Definition: config.h:203

Variable Documentation

int debug_on =0
static

Definition at line 51 of file wpickclick.c.

Referenced by cxlog(), and init_debug().