?
Solved

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

Posted on 2006-04-28
22
Medium Priority
?
386 Views
Last Modified: 2010-08-05
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,
0
Comment
Question by:waleed_makarem
22 Comments
 
LVL 3

Expert Comment

by:Darrylsh
ID: 16568742
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.
0
 

Author Comment

by:waleed_makarem
ID: 16570446
are there any method to make these changes to the EXE file iteself .

Thanks,
0
 

Author Comment

by:waleed_makarem
ID: 16572331
can you do it in visual basic 6 please .

Thanks,
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:Masta120
ID: 16574045
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
0
 

Author Comment

by:waleed_makarem
ID: 16577503
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,
0
 
LVL 5

Expert Comment

by:wings_gaurav
ID: 16577674
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
0
 

Author Comment

by:waleed_makarem
ID: 16577712
yeah , I am really so interest .
do you use Visual basic 6.0
0
 
LVL 5

Expert Comment

by:wings_gaurav
ID: 16577736
it will require vc, win 32 api.

-gaurav
0
 

Author Comment

by:waleed_makarem
ID: 16577781
Ok ,
if so , You will worth at least 500 points for it * 4(experts) =2000 points .

how long will it take to be ready
0
 
LVL 5

Expert Comment

by:wings_gaurav
ID: 16577809
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
0
 

Author Comment

by:waleed_makarem
ID: 16577854
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 .

0
 

Author Comment

by:waleed_makarem
ID: 16603679
Hi ,

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

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


Regards,
0
 
LVL 5

Expert Comment

by:wings_gaurav
ID: 16607473
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
0
 

Author Comment

by:waleed_makarem
ID: 16612964
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
0
 
LVL 5

Expert Comment

by:wings_gaurav
ID: 16613361
have uploaded the built solution and source code at

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

-wings
0
 

Author Comment

by:waleed_makarem
ID: 16613608
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
0
 
LVL 5

Expert Comment

by:wings_gaurav
ID: 16613651
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
0
 

Author Comment

by:waleed_makarem
ID: 16613726
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
0
 
LVL 5

Accepted Solution

by:
wings_gaurav earned 2000 total points
ID: 16618017
hi,

i have made the hook system wide now and uploaded the file at

http://www.4shared.com/file/1514560/3fc17eaa/hook_app_-_1.html

hope this works better with your application.

-gaurav
0
 

Author Comment

by:waleed_makarem
ID: 16618066
sorry, but it seems that it has the same problem .


Waleed
0
 

Author Comment

by:waleed_makarem
ID: 16618163
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
0
 

Author Comment

by:waleed_makarem
ID: 16639834
Dear Gaurav,

Thanks for your effort and your interest .

Regards,
Waleed
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Introduction to Processes

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question