Thread: Implementing short macros for windows®

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    68

    Implementing short macros for windows®

    Hey there!

    I thought about programming helpful macros for windows, well actually I only had one idea till now, that is writing a function that minimizes all windows and shows the desktop. It's necessary because windows key+D is broken if a program is in fullscreen or uses d3d, then the desktop is not clickable after windows key+D.

    But how would I implement this?

    I don't like having many processes, especially not a process that only does one function.

    As far as I know there is:
    * Creating a service - is it possible to add a service for these macros to run with all the other services in svchost.exe?
    * Code Injection on the fly into a process that is always active like winlogon.exe - I think it's too unstable from my previous experiences.
    * Code Injection directly into the executable of a process that is always active - Needs advanced assembling and reverse engineering skills... but is it also stable?
    * Dll Injection on the fly - also unstable from my experiences.
    * Dll Merge with the executable of an always active process - never tried something like this. The dll contains the macro function, but it can't be called without any kind of code injection, right?
    * Proxy Dll - This will work for sure without problems if I put the proxy dll in the executable's folder, right? At least I thought programs will look for resources like dlls first in its own folder and only afterwards using the PATH environment variable.

    That's it from my knowledge.

    I'm tending towards using a proxy dll, but maybe somebody knows a better method of short code execution without an executable.

    TIA,
    Hawk

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Well... either all that or just move the mouse to the right side of the taskbar...

    None of those solutions is particularly viable. Merely putting a DLL in a programs folder is going to flat out nothing because the program won't even know it's there.

    There are reasons why you can't just "screw around" with open windows, not the least of which is protecting the system against malware and trojans.
    Last edited by CommonTater; 01-16-2011 at 07:51 PM.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    None of those solutions is particularly viable. Merely putting a DLL in a programs folder is going to flat out nothing because the program won't even know it's there.
    This isn't quite true, some of the methods that Hawkin explained probably could achieve this. Proxy DLLs do work (at least, on Windows XP they do) because they replace a file that the executable needs to load in order to function (has to replaced before the application is run though).

    Well... either all that or just move the mouse to the right side of the taskbar...
    I will agree with this though, it's a very dirty fix to a pretty simple problem. That said, it seems as if you're on 7 or Vista, which I haven't had much experience with so I don't truly know the extent of the problem.

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    68
    CommonTater: I am using proxy dlls for some executables for months, which work absolutely perfect (on XP that is). It was the last part of hooking that I needed to learn, because this solves many problems. The problem is I don't know the behaviour of windows programs, if they also look for dlls in their respective program folder first or directly access the path variable.

    Care about elaborating on the "dirty fix" with "moving the mouse to the right side of the taskbar"? As mentioned I am running XP and don't even know about what topic you are talking :S

  5. #5
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    Care about elaborating on the "dirty fix" with "moving the mouse to the right side of the taskbar"? As mentioned I am running XP and don't even know about what topic you are talking :S
    Not what I mean. I mean that the way you're trying to do this (and pretty much any way apart from that which is built in to Windows) is a dirty fix to this problem. The simplest, and best, solution would be to try and use the way which Windows allows for this. So you've tried Win+D? Try Win+M which minimizes all windows. Works for me.

    Just as a side note, I don't believe that proxy DLLs are a good solution to this problem at all. To get a DLL into every process (which you would need to, for what you are wishing to do) you would need to replace a DLL that was used by all processes. This would cause a (possibly significant) performance increase as every call to that DLL (and there would be a hell of a lot of calls to it) would need to be proxied to the real DLL.

    I don't think I can go into DLL injection any more as it's quite a touchy topic. It mostly lends itself to malicious purposes.

  6. #6
    Registered User
    Join Date
    Aug 2006
    Posts
    68
    It's not what I wanted. I want to proxy one single dll of one single already active program. This is only one dll in one folder, which will be loaded only once My solution is a global hotkey for window minimizing, thus I need to run code only once.

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Hawkin View Post
    CommonTater: I am using proxy dlls for some executables for months, which work absolutely perfect (on XP that is). It was the last part of hooking that I needed to learn, because this solves many problems. The problem is I don't know the behaviour of windows programs, if they also look for dlls in their respective program folder first or directly access the path variable.
    Well, ignoring for the moment that such a practice on Win7 or Vista would probably result in the software either triggering the UAC or being tagged as malware... There is also the matter that you are tampering seriously with the work done by others... If your proxy introduces a bug or changes the program's behavior, it's likely to result in data losses or program crashes... and then lawsuits and other problems for the original creator of the software.

    Hearing you say you are doing this without knowing the behavior of windows programs is enough to send shivers down my back....


    Care about elaborating on the "dirty fix" with "moving the mouse to the right side of the taskbar"? As mentioned I am running XP and don't even know about what topic you are talking :S
    In Vista and 7, with the Aero interface placing the mouse pointer on the right side of the taskbar shows you the empty desktop... when you take it away all windows return...

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by DeadPlanet View Post
    I will agree with this though, it's a very dirty fix to a pretty simple problem. That said, it seems as if you're on 7 or Vista, which I haven't had much experience with so I don't truly know the extent of the problem.
    It's not a "dirty fix" and there's no problem... it's a built in feature of the Aero interface.

    Walk up to any windows machine running Aero (Vista, server , 7, etc) and simply move the mouse cursor to the right of the clock on the taskbar... windows gone, bare desktop exposed... then move the mouse cursor away... windows return, just like nothing happened. There's even a baloon tip there telling you what it does....

    Frankly this is why I find this whole thread a tad puzzling... on 2000 and XP (and it's servers) you only have to type WIN+D to get the same result.... WIN+D desktop... WIN+D windows return...

    Moerover... on all versions... you can right click the taskbar and select "show desktop"....

    I'm just having a real hard time figuring out why this code is even needed...
    Last edited by CommonTater; 01-18-2011 at 07:50 AM.

  9. #9
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    Quote Originally Posted by CommonTater
    It's not a "dirty fix" and there's no problem... it's a built in feature of the Aero interface.
    This is the second time that what I said was misunderstood, so I'm gonna blame myself here for not being clear enough. What I meant was that I agree with you in that this is simply solved problem by just using builtin features of Windows. What the OP is trying to do is a dirty fix to the problem.

    Quote Originally Posted by Hawkin
    It's not what I wanted. I want to proxy one single dll of one single already active program. This is only one dll in one folder, which will be loaded only once My solution is a global hotkey for window minimizing, thus I need to run code only once.
    I have no idea how proxying one single dll in on single already active program (which I'm pretty sure will not work, because Windows loads the DLL into memory at runtime. You would have to restart the program) can allow you to minimise all windows.

  10. #10
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by DeadPlanet View Post
    This is the second time that what I said was misunderstood, so I'm gonna blame myself here for not being clear enough. What I meant was that I agree with you in that this is simply solved problem by just using builtin features of Windows. What the OP is trying to do is a dirty fix to the problem.
    Thanks for that, I was indeed misunderstanding you.


    I have no idea how proxying one single dll in on single already active program (which I'm pretty sure will not work, because Windows loads the DLL into memory at runtime. You would have to restart the program) can allow you to minimise all windows.
    Well, unless he went after core components like user32 ... which would set off the Windows File Protection alarms like crazy.

    Ok... here's a real simple way to show the desktop as a global keyboard function...

    1) Open Notepad
    2) Enter the following
    Code:
    [Shell]
    Command=2
    IconFile=explorer.exe,3
    [Taskbar]
    Command=ToggleDesktop
    3) Save this file in the root of drive C: as SHOWDESKTOP.SCF
    4) now make a desktop shortcut to it... drag and drop with alt held down will work.
    5) Right click on the shortcut and select properties
    6) click on the window next to "Shortcut Key"...
    7) Press and hole CTRL and ALT (together) then type F12...
    8) Click OK to save your shortcut

    Ok now zoom a window so you can't get to the desktop...

    Type CTRL+ALT+F12 ... desktop ... CTRL+ALT+f12 ... windows...

    No fancy schmancy DLL injection crap required...
    Like I said... already there as part of standard windows.

  11. #11
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    The question I have for the OP is: What makes you think the current 'Show Desktop' command isn't implemented by minimizing all open Windows? Because I'm sure it is.

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by adeyblue View Post
    The question I have for the OP is: What makes you think the current 'Show Desktop' command isn't implemented by minimizing all open Windows? Because I'm sure it is.
    Actually the show desktop is implemented by

    ShowWindow(HWND Wind, int Flags);

    flages = SW_HIDE to hide it, then to restore it ... flags = SW_SHOWNORMAL

    If they did it by minimizing the windows might change size or positions on the screen. Also restoring a group of minimized windows doesn't give much control over which window is active.

  13. #13
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    Let me rephrase that, Show Desktop IS implemented by minimizing all other windows. If you don't believe me add this to the WndProc of your choice, run your program and press the show desktop button.

    Code:
    case WM_SIZE:
    {
         if(wParam == SIZE_MINIMIZED)
         {
              MessageBox(hwnd, L"Minimizing", L"", MB_OK);
         }
    }

  14. #14
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by adeyblue View Post
    Let me rephrase that, Show Desktop IS implemented by minimizing all other windows. If you don't believe me add this to the WndProc of your choice, run your program and press the show desktop button.
    How about that... You learn something new everyday...

  15. #15
    Registered User
    Join Date
    Aug 2006
    Posts
    68
    Okay... where to start...

    First of all to all your Aero and "dirty fix" suggestions: In my previous post I have told that I am running XP, so I don't benefit from those tricks.

    Second I only want this code for myself, on XP. Not for any other people, so I don't care at all if it works on other OS or not.

    CommonTater: I totally forgot or didn't even knew about windows hotkeys for shortcuts. I tried your method using a shortcut to the original "Show Desktop.scf"-file (which contains the same code you posted) and tried several hotkeys (ctrl+alt+d, ctrl+alt+s, ctrl+alt+e, ctrl+alt+f12, ctrl+alt+f11) and had problems with all of them. with ctrl+alt+d and ctrl+alt+f11 the explorer was freezing completely for 5-15 seconds, then randomly either proccing the "show desktop"-effect or not. Unfortunately the cance of activating was 2-5%. I also applied a hotkey to a shortcut to a folder, there was the same: If applied to several hotkeys such as ctrl+alt+d, there was complete explorer freeze (all interface such as taskbar, open folders) for 5-15 seconds and then randomly appearing the folder i hotkey'd. Chance here: 50%.

    Now I know why I don't know about this window function, it simply sucks. But thanks for trying to understand the topic, what I wanted is to hear experiences/solutions from other people, not criticize or discuss my solutions (except my questions), because those I can do on my own and just wanted to list them to avoid somebody posting the same ideas.

    There is also the matter that you are tampering seriously with the work done by others... If your proxy introduces a bug or changes the program's behavior, it's likely to result in data losses or program crashes... and then lawsuits and other problems for the original creator of the software.

    Hearing you say you are doing this without knowing the behavior of windows programs is enough to send shivers down my back....
    I am not tampering with work of anybody. You might want to look up the definition of a proxy dll. The dll's are my work and act as man in the middle, redirecting every function call back to the program. I am also autorunning 2 of my programs, which I can use for my hotkey code, if you are so fussy If there are bugs or crashes, it's my fault, and I can solve them because I wrote the code, that is running on my pc
    And I only said code and dll injection have flaws, not proxy dlls. There is no "unknown behaviour", proxy dlls work perfectly. I haven't had a single crash or bug in a year of using.

    I have no idea how proxying one single dll in on single already active program (which I'm pretty sure will not work, because Windows loads the DLL into memory at runtime. You would have to restart the program) can allow you to minimise all windows.
    Sorry, I didn't express myself good enough, in my last post I didn't mean "an already active program" but an autorun program. Hence after a reboot the program would run with my proxy dll instead. Restarting it has the same effect, yes.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Accessing Structures Inside Structures
    By Mellowz in forum C Programming
    Replies: 1
    Last Post: 01-13-2008, 03:55 AM
  2. Help calling function is asm
    By brietje698 in forum C++ Programming
    Replies: 24
    Last Post: 12-06-2007, 04:48 PM
  3. Say what? - Weird error.
    By Blackroot in forum C++ Programming
    Replies: 6
    Last Post: 08-15-2006, 11:54 PM
  4. Color Variety
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 10-23-2002, 09:17 AM
  5. My Allegro Program will not run...
    By Vicious in forum Game Programming
    Replies: 17
    Last Post: 06-14-2002, 12:49 AM