ToMKoL Posted July 2, 2022 Posted July 2, 2022 I've wrote small loader for an old crackme. This crackme searches for Olly window class and when not found my loader tries to emulate it. For this I'm creating simple window. Main window is dialog box. On dialog icon is shown normally but not on created window. I've tried many things. Using two different icons for each window, using some default icon from os, different window styles but without luck. I'm attaching full source and target. If You have some other ideas please share. hmx0101_secret1.zip
fearless Posted July 2, 2022 Posted July 2, 2022 I would use ICON_SMALL instead of ICON_BIG for the WM_SETICON. ICON_BIG is 1, ICON_SMALL is 0, currently you are passing 1 as the value which is ICON_BIG. IDI_ICON doesnt seem to have an id that i can see. your icon in the resource file is assigned the value of 10. You can set IDI_ICON to 10 somewhere in code or use 10 directly instead of IDI_ICON so that it references the icon in the resource file: 10 ICON "loader.ico" Maybe a #define IDI_ICON 10 is needed somewhere in code if not in some resource file - perhaps i missed that somewhere. If registering a window procedure, you could save the icon loaded, so that it can be used in other WM_SETICON calls, like for dialogs or other windows in your project that the main window calls at some point. hIcoMain = LoadIconA(hInst, MAKEINTRESOURCE(IDI_ICON)); wc.hIcon = hIcoMain; wc.hIconSm = hIcoMain; Then using WM_INITDIALOG is fine to put the code to load up icon for dialogs: SendMessageA(hWnd, WM_SETICON, ICON_SMALL, hIcoMain); 1
ToMKoL Posted July 3, 2022 Author Posted July 3, 2022 (edited) Didn't try ICON_SMALL. Will test it. -> Tested it and no difference. Dialog have icon and window not. IDI_ICON is defined in 'resource.h' file. Icon handle is saved during initialization of dialog. Edited July 4, 2022 by ToMKoL added more information
Teddy Rogers Posted July 5, 2022 Posted July 5, 2022 The API docs for WM_SETICON (and WM_GETICON) define where the icons need to be used. Quote The system displays the large icon in the ALT+TAB dialog box, and the small icon in the window caption. LoadIcon uses the system default metric (icon size) of SM_CXICON and SM_CYICON. You can confirm the system size using GetSystemMetrics. If you have 32x32 icon and the system default is 16x16 it is not intended to work. Instead of having multiple icons what I generally do is have one large icon e.g. 64x64 or 128x128 and scale icons to suite the system metrics and window DPI. If your program is DPI aware you can use a DPI value with GetSystemMetricsForDpi to get the icon dimensions that are required. Some of the newer API's starting with Vista may be of interest. LoadIconWithScaleDown allows you to use a large icon to scale down the icon to the required size. LoadIconMetric allows you to specify the metric or size of the icon and resize up or down accordingly... Ted.
ToMKoL Posted July 5, 2022 Author Posted July 5, 2022 Problem is somewhere else. I did try some default icons from system and they also didn't work on window. On dialog any icon that I tried is displayed. On window none.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now