473,486 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2185
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
2590
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
4294
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
1674
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
9297
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
297
by: | last post by:
Hi,all U can download dotNetHookLibrary in http://dotnethook.sourceforge.net . for instance, I have the fellowing code :...
2
1222
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
8226
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
5072
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
2729
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
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7132
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
7341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5439
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,...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.