Link to home
Start Free TrialLog in
Avatar of waleed_makarem
waleed_makarem

asked on

Disable right mouse Click in EXE Program... (I'll pay for the solution)

Dear Experts ,

I have a software quite old (1998). it is in EXE . I think it is made by BORLAND C 3.00 because it contains libraries files for BoRLAND C 3.00 .It is working fine . but the problem is that I WANT TO DISABLE RIGHT MOUSE CLICK (as it displays Copy,Cut and past that I do NOT want user to access).
This is quite easy for you all , but the real problem is that the software I have is COMPILED INTO EXE .

I guess someone may work on the software as ASSEMBLY or may DEcompile it .

I will pay for the solution

Thanks,
Avatar of Darrylsh
Darrylsh

You have to use a system wide mouse hook to capture the right clicks, once captured you check to see if they are for the application you are trying to block, if they are, you basically just "eat" that input but if they are not then you pass them on so that the right click still works elsewhere as intended.
Avatar of waleed_makarem

ASKER

are there any method to make these changes to the EXE file iteself .

Thanks,
can you do it in visual basic 6 please .

Thanks,
I believe you can override the mouse down event, and test if the button's value (1 = left button, 2 = right button).

If the button is equal to 2, do nothing.  If 1, then do what ever you need it to.

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
     ' add your code here
End Sub
this is ok , but how to do this with HOOKING mouse events + Testing that this event is triggered from the application of interest not for all applications .

Can you do some code please .

Thanks,
Hi,

If you are still interested, there is a way. Code to load a dll can be injected into the application and the actual start address of the application can be stored so that the dll can pass the control to the entry point of the executable. This injected dll will place hook for mouse messages for the application. This can be done and will require some bit of effort. Let me know if you are interested.

Regards,
Gaurav
yeah , I am really so interest .
do you use Visual basic 6.0
it will require vc, win 32 api.

-gaurav
Ok ,
if so , You will worth at least 500 points for it * 4(experts) =2000 points .

how long will it take to be ready
give me a day or two. Just to understand the requirements clearly – ALL right mouse clicks will get disabled on an exe fro which you don’t have source code i.e. just the exe.

Right?

-gaurav
yeah , but for a certain application ONLY , ie to disable it in A working WORD , but does NOT affect opertion of other softwares eg EXCEL , WORDPAD ,... etc .

Hi ,

Any news .................. .

I hope there will be good solution soon .
Waiting for your genius code .


Regards,
hi,

make a vc win 32 application project named launch - add a file main.cpp
//////////////////////////////////////////////////////////////////////////
//main.cpp for launcher
#include <windows.h>

typedef void (__stdcall *SetHook)(HHOOK);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char * strCmdLine, int nCmdShow)
{

      HINSTANCE hHookLib = LoadLibrary("hook.dll");

      // ff handle is found
      if(hHookLib)
      {
            
            // get address to hook proc
            HOOKPROC  pHookProc = (HOOKPROC)GetProcAddress(hHookLib, "MouseProc");            
            SetHook pSetHook = (SetHook)GetProcAddress(hHookLib, "SetHook");
            
            STARTUPINFO si;
            PROCESS_INFORMATION pi;
            ZeroMemory( &si, sizeof(si) );
            si.cb = sizeof(si);
            ZeroMemory( &pi, sizeof(pi) );

            // create process
            if(CreateProcess(strCmdLine,"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
            {
                  //set a mouse hook
                  HHOOK hHook = SetWindowsHookEx(WH_MOUSE, pHookProc, hHookLib, pi.dwThreadId);
                  // pass teh refrence to the dll so that it can use it
                  pSetHook(hHook);

                  // wait for the process to complete
                  WaitForSingleObject(pi.hProcess, INFINITE);

                  // remove the hook
                  UnhookWindowsHookEx(hHook);

                  // close process handle
                  CloseHandle(pi.hProcess);
                  CloseHandle(pi.hThread);
            }
      }

      return 0;
}
///////////////////////////////

create a dll project named hook in vc - add a file main.cpp and paste the following code
////////////////////////////////////////////
// main.cpp - for hook.dll
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

// ".shared" is defined in exports.def to allow
//  all instances of the dll to share these variables
#pragma data_seg(".shared")
      HHOOK      hHook = 0;  
#pragma data_seg()

// Set the values for the window and hook for the windows hook

void WINAPI SetHook(HHOOK hk)
{
      hHook = hk;
}

// HookProc
LRESULT CALLBACK MouseProc(int nCode,  WPARAM wParam, LPARAM lParam)
{
      if(nCode >= 0)
      {
            // if right button then consume message
            switch(wParam)
            {
            case WM_RBUTTONDOWN:
            case WM_RBUTTONUP:
                  return 1;
            }
      }
      return CallNextHookEx(hHook, nCode, wParam, lParam);
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID)
{
      if (fdwReason == DLL_PROCESS_ATTACH)
      {
            DisableThreadLibraryCalls(hinstDLL);
      }
      return TRUE;
}

//////////////////////////////////////

add another file to the project named exports .def
////////////////
EXPORTS
      SetHook
      MouseProc

SECTIONS
      .shared READ WRITE SHARED
//////////////

in the project setting link tab append the text below to define the exports

/def:".\exports.def"

compile both the projects and you would get launch.exe and hook.dll. place thse files in the directory of the target application and say launch.exe <full path of your application>.

I can send you built projects and source if you can give me your email address.
regards,
Gaurav
wings_gaurav@yahoo.com
Dear Gaurav ,

Thanks for the code , I hope you can send me the built and the source code projects .
I am very very interested to try  it .

My mail is
waleed.makarem@gmail.com

thanks again .

waleed
have uploaded the built solution and source code at

http://www.4shared.com/file/1508488/d9ed2729/hook_app.html

-wings
I have tested it for notepad , it worked well , but when i tested it for my application , it gave me the following message Box during loading the software
"The Logon system has been tampered with . The Adminstrator will need to re-installe.  "
This message box has a title "Security Check failure"

When I press the OK button of this message box , the software closes .

What do you think .


Thanks,
Waleed
i think the software is checking for hooks and displaying the error message! this makes the problem more complex. there might be a way to add the hook after the logon occurs. for this to de done the code will need to be modified to wait for the main window to open and therafter add the hook. Untill i can have a look at the application i will not be able to help you with this.

regards,
gaurav
what if we made a simple software , it is a separate software that loads when microsoft windows loads at start up . it checks mouse click then check if the software that triggers the mouse click . if has the same software name of interest, then it will cancel the mouse click event .



waleed
ASKER CERTIFIED SOLUTION
Avatar of wings_gaurav
wings_gaurav

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry, but it seems that it has the same problem .


Waleed
i've tried it for winamp and word and excel , it worked great , BUT not for my application .
I do not know why .

thanks,
Waleed
Dear Gaurav,

Thanks for your effort and your interest .

Regards,
Waleed