Click here to Skip to main content
15,913,773 members
Home / Discussions / C#
   

C#

 
QuestionSupressing a MessageBox Pin
eggie525-Mar-06 7:40
eggie525-Mar-06 7:40 
AnswerRe: Supressing a MessageBox Pin
Ravi Bhavnani25-Mar-06 8:06
professionalRavi Bhavnani25-Mar-06 8:06 
GeneralRe: Supressing a MessageBox Pin
eggie525-Mar-06 8:08
eggie525-Mar-06 8:08 
AnswerRe: Supressing a MessageBox Pin
Luis Alonso Ramos25-Mar-06 8:59
Luis Alonso Ramos25-Mar-06 8:59 
GeneralRe: Supressing a MessageBox Pin
cnich2325-Mar-06 9:38
cnich2325-Mar-06 9:38 
GeneralRe: Supressing a MessageBox Pin
Luis Alonso Ramos25-Mar-06 9:41
Luis Alonso Ramos25-Mar-06 9:41 
GeneralRe: Supressing a MessageBox Pin
eggie526-Mar-06 6:48
eggie526-Mar-06 6:48 
GeneralRe: Supressing a MessageBox Pin
Luis Alonso Ramos26-Mar-06 15:13
Luis Alonso Ramos26-Mar-06 15:13 
Patching is actually changing the code in the DLL. In you case, suppose you have somthing like this in machine-type pseudocode:
call DoSomething
if error code != 0
   go to error
 
call DoSomethingBecauseNoError
return
 
error:
call MessageBox("error!!")
return
Suppose you find that code in the DLL and actually modify the file so that the insctruction go to error is changed to a NOP (which is an Intel x86 assembly language instruction that actually does nothing). The next time the DLL is loaded and executed, the DoSomethingBecauseNoError call will always be executed, even if there was a previous error. That's patching: modifying some already-compiled code.

I can also be useful in cracking programs. Suppose you have an app that calls a funcion to check whether it's registered or not. If you patch the beginning of that function (by changing the first instruction for a return true) it will always seem as registered (that's what some cracks actually do.)

Hooks are something totally different. A hook is a way to register your code so it's called before or after some other code, and it can optionally alter the normal behavior. In this case the original code is not modified, but the operating system or the code-to-be-called must provide a way to be hooked.

Windows provides several types of hooks. One of them, the WH_CBT hook, lets your hook procedure be called everytime the system is about to create a window, and you can prevent it from doing so. This way, you could see every window created, and if it's the specific message box, just prevent it.

You can find more information in MSDN:

About Hooks[^]

CBTProc[^]

Your hook procedure must reside in a DLL that will be loaded in the target process, so I seriously recommend it's written in plan Win32 API code. If you write it in .NET, the whole .NET Framework will be loaded in the target process, and there could be a conflict if that process uses another version of .NET.

I hope this helps! Smile | :)

Luis Alonso Ramos
Intelectix
Chihuahua, Mexico

Not much here: My CP Blog!
GeneralRe: Supressing a MessageBox Pin
eggie526-Mar-06 15:28
eggie526-Mar-06 15:28 
GeneralRe: Supressing a MessageBox Pin
Luis Alonso Ramos26-Mar-06 15:34
Luis Alonso Ramos26-Mar-06 15:34 
GeneralRe: Supressing a MessageBox Pin
eggie526-Mar-06 15:41
eggie526-Mar-06 15:41 
GeneralRe: Supressing a MessageBox Pin
Luis Alonso Ramos26-Mar-06 15:47
Luis Alonso Ramos26-Mar-06 15:47 
GeneralRe: Supressing a MessageBox Pin
eggie526-Mar-06 6:42
eggie526-Mar-06 6:42 
GeneralRe: Supressing a MessageBox Pin
cnich2327-Mar-06 4:19
cnich2327-Mar-06 4:19 
QuestionErasing lines Pin
CoolASL25-Mar-06 6:31
CoolASL25-Mar-06 6:31 
AnswerRe: Erasing lines Pin
Robert Rohde25-Mar-06 7:31
Robert Rohde25-Mar-06 7:31 
GeneralRe: Erasing lines Pin
CoolASL26-Mar-06 23:04
CoolASL26-Mar-06 23:04 
QuestionHow can i bind two controls together in witch that when one control scrolls the other scrolls too? Pin
Bobby88725-Mar-06 6:06
Bobby88725-Mar-06 6:06 
AnswerRe: How can i bind two controls together in witch that when one control scrolls the other scrolls too? Pin
Ravi Bhavnani25-Mar-06 8:09
professionalRavi Bhavnani25-Mar-06 8:09 
QuestionWindows Service Pin
hung_ngole25-Mar-06 6:04
hung_ngole25-Mar-06 6:04 
QuestionDrawing a line in ASP.NET Pin
naglbitur25-Mar-06 5:00
naglbitur25-Mar-06 5:00 
AnswerRe: Drawing a line in ASP.NET Pin
leppie25-Mar-06 6:51
leppie25-Mar-06 6:51 
AnswerRe: Drawing a line in ASP.NET Pin
Guffa25-Mar-06 7:18
Guffa25-Mar-06 7:18 
QuestionCorrection: How to define an array in a class Pin
IceWater4225-Mar-06 4:54
IceWater4225-Mar-06 4:54 
AnswerRe: Correction: How to define an array in a class Pin
Nicholas Butler25-Mar-06 5:26
sitebuilderNicholas Butler25-Mar-06 5:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.