Understanding functions hooks - hook

This is my first post in stackoverflow, eventhough I'v been reading here for more than a year.
I would like to ask some questions about function hooking, and would be really glad to have some answers.
Say I created an executable and I would like to hide it in the list of the task manager so it would be invisible.
I could hook the function in the task manager that is in charge of displaying all the running processes.
I know that in order to do such a thing I would need to start by injecting my own DLL to taskmgr.exe, and taking over the required function using one of many techniques.
My question are the following:
1.How could I get the name of my requested function ? Would I disassemble taskmgr.exe and search there ? I would like to hear a little more about techniques from this kind.
2.Say I know my function name, how could I get its run time address in order to invoke my hook ? Is the address I will find while disassembling the exe the same as the run time address ? If not, how would I find it ?
3.A general question about hooking functions, Say I hook windows messagebox function, and would override it so that each message that should be printed would print "ABCDEF", Would that affect each process that uses the messagebox function or only my process ? Would love to get an explanation about this issue.
Thanks alot in advance :)
Michael.

Related

Logging with multithreading

I have two threads running at the same time which are picking up items from the same queue and processing them. However, sometimes I get exceptions because they are trying to access the same object, when one has already picked it up. I looked up solutions online and people said to use logs to tell one thread or the other to wait. How does this work? What approach would you take to use logs?
Take a look at this link. it describes what a lock is. without knowing the language you are using I cant really be more specific.

Catching resource filename errors at compile time

I'm doing my first iOS App with Monotouch and I'm loading quite a lot of images from my resources directory. Every now and then I get a typo in a filename and the app will then crash on me spewing out some unintelligible error message. (I'll try adding deciphering stack traces to my skill set any day now ...)
I was thinking that there must be a smarter way to handle this. For example one could have a utility script that goes through the resources directory and constructs a list of global constants based on its contents. Each file in the resources gets an entry.
So that MyResources/Icons/HomeIcon.png will be represented by the constant MyResources.Icons.HomeIcon_png. Then one could have something like Inotify (don't know what that would be on Mac) watch the resources directory and regenerate the constants file on every change.
This would of course also give nice autocompletion for resources.
Maybe there's already something like this is already in Monodevelop or online somewhere? Otherwise how would I go about setting it up?
Or maybe there's some other smart way of mitigating the problem?
Your primary problem is typos in resource names are not caught early, and only cause crashes when the app is actually ran.
Your proposed solution of a list of global constants generated based on the available resources is kind of neat, but as far as I know this does not exist yet.
In the mean time, you could manually construct this list of global constants, and create a unit test that verifies all the elements in this list are valid resources (by looping through them automatically, of course - adding a resource to the list should not require a change to the test).
This way you can catch typos earlier (when you run the unit test rather than when you run the app), which is your primary concern. Additionally, if you ever find/write the script you envision, your application code is already prepared.
I filed an enhancement bug on Xamarin bugzilla for you: https://bugzilla.xamarin.com/show_bug.cgi?id=3760
So I spent four precious hours to cook up this little python script that sort of solves my problem. For now it's the best solution to my problem.
http://github.com/oivvio/Monodevelop-Resources-as-Constants

Life ray life cycle method in JSR-186 and 168

I am newbie in Life-ray even portal application. I just started study last 15 days, and yesterday I attend an interview, they ask me following question, some of the question I answered also, but help me to understand about following questions.
What environment have you worked.
Answer: I was using eclipse IDE and plugin SDK(as per them it was not correct,probably I am wrong)
If we have a Page containing a text field and button, what will happen if I click on button.
Answer: I asked it depends what framework we are using struts or spring. then they asked if you are not using any framework then,
Then i said Life-cycle methods of portlet( init, processAction, render, destroy)
as per them this was not correct also.
Please help me to understand the correct answer.
Is there any thing specific to life-ray portal, I am quite confused.
And is there any life cycle methods difference between JSR-186 and JSR-268.
Thanks
What environment have you worked
That entirely depends one what they mean by environment as it could be programming environment (IDE, other tools, languages) or it could work environment (teams, methodologies, etc). Could you elaborate more on what they asked?
If we have a Page containing a text field and button, what will happen if I click on button
Again this is really open ended, and depends on what code is written. However we assume that the button is linked to a form, who's action is to invoke the Portlets process action method, then that's would would happen. After that it would probably enter the render phase again, but it depends what code has been written inside the portlet!
I personally think their questions are a bit generic, and they may have been looking for you to narrow down their questions more.
What do other people think?

Create a New .Net Profiler Api

i m a new programmer in .Net Profiler and Visual C++,
i read many forums and weblogs for .Net Profiling and i have this question.
my Profiler application must be a unmanaged code or i can use some class in .Net in my application? and what type of project i must create ATL with MFC Or ..?
another question is how can i register my profiler dll file that every application of my computer use this profiler?
where the best situation for re-write IL of a method (Enter method of profiler or JITCompilationStarted)?
how can i get input variables of old method and send to new method?
how can i change IL of a property or whole of a class?
i want chane all datetime format of my dlls, and i think that i must search name of those method in JITCompilationStarted and then rewrite that methods,Do u have any better solution? thanks alot.
It is good that you want to try this. I would suggest that you be aware of some old ideas about profiling that are less than helpful, and try to improve on them.
I would suggest that the primary focus should be on lines of code, not functions, and that the most useful statistic to get is, for each line, the percent of time it is responsible for (i.e. on the call stack). (The advantage of getting percentage is that you don't have to care how long things take, how many times they are invoked, or whether they are competing with other processes.)
I think the best way to get that information is by means of stack samples taken at random wall-clock times. Don't exclude samples just because they occur when the program is blocked, unless you want to be blind to needless I/O. A good approach is to let the user turn sampling on/off, so you don't take a lot of samples while waiting for user input.
An example of a good profiler that takes this approach is RotateRight/Zoom. Good luck.

Processing Linux SIGnals using Gambas

I would like to send a (as yet undetermined) SIGnal from a bash script to a Gambas program when a specific file has been changed.
How can I get my Gambas program to process this SIGnal?
The gb.signal component allows you to manage signals. You can intercept them, ignore them, and so on. See http://gambaswiki.org/wiki/comp/gb.signal for the details.
If the documentation is anything to go by, this doesn't seem possible. However, I would suggest asking the same question on the Gambas mailing list (and/or link to this question on Stack Overflow). Please report back if you get an answer via the mailing list.
According to http://www.mail-archive.com/gambas-user#lists.sourceforge.net/msg01890.html and http://www.nabble.com/Question-about-signal-management-inside-gambas-console-program---td20626972.html, it is not yet possible.

Resources