473,396 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How shall I injects code into methods of an assembly by DotNetHook ?

Hi,all

U can download dotNetHookLibrary in http://dotnethook.sourceforge.net .

for instance, I have the fellowing code :
//------------------------------------------------------------------------
using System;
namespace hook
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
testHook();
}
public static void testHook()
{
Console.WriteLine("Help me");

}
}
}
//-------------------------------------------------------------------------
If anyone know how to injects code into testHook() by DotNetHook ,plz tell
me!

BTW,if you can do it, plz email to me, My email is Zh***********@163.com .
:)
thank you
ZhongHua
Nov 17 '05 #1
5 2183
What do you mean by: "inject code"??? do you mean creating methods in
runtime?
like Reflection.Emit does?

Eyal.

Nov 17 '05 #2
I'm missing the top of the thread, but I assume he's talking about Aspect
Orientated Programming. AOP involves using some weird compiler tricks in
literally insert extra code into a method. A bunch of voodoo BS if you ask
me. I've never seen a non-trivial example where it would be useful, and
because the code doesn't match the source, debugging is impossible.

--
Jonathan Allen
"Eyal Safran" <ey**@mokedor.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
What do you mean by: "inject code"??? do you mean creating methods in
runtime?
like Reflection.Emit does?

Eyal.

Nov 17 '05 #3


Jonathan Allen wrote:
I'm missing the top of the thread, but I assume he's talking about Aspect
Orientated Programming. AOP involves using some weird compiler tricks in
literally insert extra code into a method. A bunch of voodoo BS if you ask
me. I've never seen a non-trivial example where it would be useful, and
because the code doesn't match the source, debugging is impossible.


Sounds like Reflection.Emit ... creating types and methods in runtime.

Eyal.

Nov 17 '05 #4
Jonathan Allen <x@x.x> wrote:
I'm missing the top of the thread, but I assume he's talking about Aspect
Orientated Programming. AOP involves using some weird compiler tricks in
literally insert extra code into a method. A bunch of voodoo BS if you ask
me. I've never seen a non-trivial example where it would be useful, and
because the code doesn't match the source, debugging is impossible.


For plenty of non-trivial examples where AOP is useful, look at the
documentation for the Spring Framework (http://www.springframework.org)
where it's mostly used for declarative security and transaction
support.

At work we're using it in conjunction with annotations (the Java
version of attributes) for declaring code boundaries that should be
logged when an exception occurs - it saves wrapping each method in the
same try/catch/log/rethrow block which would otherwise be necessary.

I believe this is one area where .NET is behind Java, unfortunately. I
would love to be able to decorate methods in UI class with an attribute
called something like [RunInUIThread] which would automatically check
whether or not Control.Invoke was required and use it if so...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #5
Yes,what you say is right ! but i just want to do it by DotnetHook!
<zh******@rinpak.com.cn>

"Eyal Safran" <ey**@mokedor.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
What do you mean by: "inject code"??? do you mean creating methods in
runtime?
like Reflection.Emit does?

Eyal.

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike Malter | last post by:
I am just starting to work with reflection and I want to create a log that saves relevant information if a method call fails so I can call that method again later using reflection. I am...
1
by: Abdessamad Belangour | last post by:
Hi all, An assembly is composed of a set of modules. An Assembly and a Module classes have a GetTypes() methods. Moreover, an Assembly class has a GetExportedTypes() method. 1. This means that if...
2
by: Abdessamad Belangour | last post by:
Hi all, and thanks for previous answers (especially Nicholas Paldino) An assembly is composed of a set of modules. The module class has a method for reading global methods GetMethods(). My...
192
by: Vortex Soft | last post by:
http://www.junglecreatures.com/ Try it and tell me what's happenning in the Microsoft Corporation. Notes: VB, C# are CLS compliant
0
by: | last post by:
Hi,all U can download dotNetHookLibrary in http://dotnethook.sourceforge.net . for instance, I have the fellowing code :...
2
by: Alexander Muylaert | last post by:
Hi I'm trying optimize certain pieces of my code by generating and compiling the source at runtime. I need to make 2 methods for each class, a read and a write. I would like to do this...
4
by: Brian Richards | last post by:
Is it possible to run code in an assembly when it's loaded? In my case I have an assembly that requires that the users path be setup correctly or GetTypes() will throw an exception. Looking for a...
5
by: Peter Ritchie [C# MVP] | last post by:
I've purposely been ignoring a CA2122 warning in some C++ interop code I've been working on for quite some time. I've just recently had the cycles to investigate the warning. The warning message...
26
by: anonieko | last post by:
In the past I always used "" everywhere for empty string in my code without a problem. Now, do you think I should use String.Empty instead of "" (at all times) ? Let me know your thoughts.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.