Click here to Skip to main content
15,887,946 members
Home / Discussions / C#
   

C#

 
QuestionIs there a way in .NET to access the bytecode/IL/CLR that is currently running? Pin
blackblizzard13-Apr-10 20:43
blackblizzard13-Apr-10 20:43 
AnswerRe: Is there a way in .NET to access the bytecode/IL/CLR that is currently running? Pin
PIEBALDconsult14-Apr-10 4:31
mvePIEBALDconsult14-Apr-10 4:31 
GeneralRe: Is there a way in .NET to access the bytecode/IL/CLR that is currently running? Pin
blackblizzard14-Apr-10 4:39
blackblizzard14-Apr-10 4:39 
GeneralRe: Is there a way in .NET to access the bytecode/IL/CLR that is currently running? Pin
PIEBALDconsult14-Apr-10 5:08
mvePIEBALDconsult14-Apr-10 5:08 
GeneralRe: Is there a way in .NET to access the bytecode/IL/CLR that is currently running? Pin
blackblizzard14-Apr-10 5:18
blackblizzard14-Apr-10 5:18 
GeneralRe: Is there a way in .NET to access the bytecode/IL/CLR that is currently running? Pin
PIEBALDconsult14-Apr-10 5:29
mvePIEBALDconsult14-Apr-10 5:29 
GeneralRe: Is there a way in .NET to access the bytecode/IL/CLR that is currently running? Pin
blackblizzard14-Apr-10 5:39
blackblizzard14-Apr-10 5:39 
AnswerRe: Is there a way in .NET to access the bytecode/IL/CLR that is currently running? Pin
Daniel Grunwald14-Apr-10 6:03
Daniel Grunwald14-Apr-10 6:03 
I would use Mono.Cecil to modify the binaries on disk.
Ideally you'd add a reference to a helper assembly, and use Cecil only to replace the ldfld/stfld instructions with calls to a method in your helper assembly (passing the field by-ref and/or as metadata token).

However, there's another option for bytecode modification that's not well-known: the .NET profiler API.
Using the profiler API, you can register a hook that will be called by the .NET framework to modify the IL bytecode immediately before it's JIT-compiled.
This way you can also instrument code that's dynamically loaded (Reflection.Emit). But it's much harder to use than Cecil because any changes to metadata (e.g. adding a reference to one of your methods) have to be registered with the running .NET instance, and there are some limitations on what metadata you're allowed to change at run-time.

Are you trying to implement software transactional memory for .NET? Even using the powerful profiler API, you'll likely run into limitations (e.g. when .NET calls into native code), not to mention performance problems.
GeneralRe: Is there a way in .NET to access the bytecode/IL/CLR that is currently running? [modified] Pin
blackblizzard14-Apr-10 6:32
blackblizzard14-Apr-10 6:32 
QuestionGet output from console window (which is a different process) Pin
Programm3r13-Apr-10 20:19
Programm3r13-Apr-10 20:19 
AnswerRe: Get output from console window (which is a different process) Pin
Martin Jarvis13-Apr-10 20:44
Martin Jarvis13-Apr-10 20:44 
GeneralRe: Get output from console window (which is a different process) Pin
Programm3r13-Apr-10 20:56
Programm3r13-Apr-10 20:56 
AnswerRe: Get output from console window (which is a different process) Pin
Programm3r13-Apr-10 21:11
Programm3r13-Apr-10 21:11 
AnswerRe: Get output from console window (which is a different process) Pin
PIEBALDconsult14-Apr-10 3:24
mvePIEBALDconsult14-Apr-10 3:24 
Questiondrawing semi transparent boxes over richtextbox Pin
NarVish13-Apr-10 20:16
NarVish13-Apr-10 20:16 
QuestionWindows Forms Application versus Web Application Pin
polycom12313-Apr-10 19:28
polycom12313-Apr-10 19:28 
AnswerRe: Windows Forms Application versus Web Application Pin
Programm3r13-Apr-10 20:23
Programm3r13-Apr-10 20:23 
GeneralRe: Windows Forms Application versus Web Application Pin
polycom12313-Apr-10 20:49
polycom12313-Apr-10 20:49 
AnswerRe: Windows Forms Application versus Web Application Pin
Dan Mos14-Apr-10 3:50
Dan Mos14-Apr-10 3:50 
GeneralRe: Windows Forms Application versus Web Application Pin
polycom12314-Apr-10 18:19
polycom12314-Apr-10 18:19 
GeneralRe: Windows Forms Application versus Web Application Pin
Michael J. Eber16-Apr-10 21:02
Michael J. Eber16-Apr-10 21:02 
Questionhosting control in datagrid cell Pin
Member 59031013-Apr-10 19:20
Member 59031013-Apr-10 19:20 
AnswerRe: hosting control in datagrid cell Pin
Abhinav S13-Apr-10 19:28
Abhinav S13-Apr-10 19:28 
GeneralRe: hosting control in datagrid cell Pin
Member 59031013-Apr-10 19:58
Member 59031013-Apr-10 19:58 
AnswerRe: hosting control in datagrid cell Pin
nagendrathecoder13-Apr-10 21:23
nagendrathecoder13-Apr-10 21:23 

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.