Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » MSIL » General » Downloads
 
Add your own
alternative version

ILRewriting for beginners

, 27 Sep 2012 Ms-PL
Runtime IL-Rewriting can be used to add behavior such as logging to applications, or redirect calls from one API to another. This article and accompanying source code explains how to substitute a method call at runtime.
ILRewriting_demo-noexe.zip
ILRewriting_demo
ILRewriting_demo.zip
ILRewriteProfiler.dll
InterceptApp.exe
InterceptLib.dll
SampleApp1.exe
ILRewriting_src.zip
ILRewriting_src
ILEmitTest
Properties
ILRewriteProfiler
exports.def
ILRewriteProfiler.vcxproj.filters
ILRewriteProfiler.vcxproj.user
InterceptApp
app.aps
app.ico
InterceptApp.vcxproj.filters
InterceptApp.vcxproj.user
InterceptLib
InterceptLib.snk
Properties
SampleApp1
Properties
SampleApp1.snk

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleApp1", "SampleApp1\SampleApp1.csproj", "{3CE2EC8D-B822-4526-BB69-760302F59A1F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InterceptApp", "InterceptApp\InterceptApp.vcxproj", "{2F6F3CBA-BEB1-4C74-B483-B3E1FD991FF6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ILRewriteProfiler", "ILRewriteProfiler\ILRewriteProfiler.vcxproj", "{F3C2ED90-7A65-4394-8B21-5631F67C8546}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterceptLib", "InterceptLib\InterceptLib.csproj", "{87C29AA9-F692-4666-BA23-938127D4C84B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILEmitTest", "ILEmitTest\ILEmitTest.csproj", "{446B93D8-A96C-491C-A266-38665098C154}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Debug|Mixed Platforms = Debug|Mixed Platforms
		Debug|Win32 = Debug|Win32
		Debug|x86 = Debug|x86
		Release|Any CPU = Release|Any CPU
		Release|Mixed Platforms = Release|Mixed Platforms
		Release|Win32 = Release|Win32
		Release|x86 = Release|x86
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{3CE2EC8D-B822-4526-BB69-760302F59A1F}.Debug|Any CPU.ActiveCfg = Debug|x86
		{3CE2EC8D-B822-4526-BB69-760302F59A1F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
		{3CE2EC8D-B822-4526-BB69-760302F59A1F}.Debug|Mixed Platforms.Build.0 = Debug|x86
		{3CE2EC8D-B822-4526-BB69-760302F59A1F}.Debug|Win32.ActiveCfg = Debug|x86
		{3CE2EC8D-B822-4526-BB69-760302F59A1F}.Debug|x86.ActiveCfg = Debug|x86
		{3CE2EC8D-B822-4526-BB69-760302F59A1F}.Debug|x86.Build.0 = Debug|x86
		{3CE2EC8D-B822-4526-BB69-760302F59A1F}.Release|Any CPU.ActiveCfg = Release|x86
		{3CE2EC8D-B822-4526-BB69-760302F59A1F}.Release|Mixed Platforms.ActiveCfg = Release|x86
		{3CE2EC8D-B822-4526-BB69-760302F59A1F}.Release|Mixed Platforms.Build.0 = Release|x86
		{3CE2EC8D-B822-4526-BB69-760302F59A1F}.Release|Win32.ActiveCfg = Release|x86
		{3CE2EC8D-B822-4526-BB69-760302F59A1F}.Release|x86.ActiveCfg = Release|x86
		{3CE2EC8D-B822-4526-BB69-760302F59A1F}.Release|x86.Build.0 = Release|x86
		{2F6F3CBA-BEB1-4C74-B483-B3E1FD991FF6}.Debug|Any CPU.ActiveCfg = Debug|Win32
		{2F6F3CBA-BEB1-4C74-B483-B3E1FD991FF6}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
		{2F6F3CBA-BEB1-4C74-B483-B3E1FD991FF6}.Debug|Mixed Platforms.Build.0 = Debug|Win32
		{2F6F3CBA-BEB1-4C74-B483-B3E1FD991FF6}.Debug|Win32.ActiveCfg = Debug|Win32
		{2F6F3CBA-BEB1-4C74-B483-B3E1FD991FF6}.Debug|Win32.Build.0 = Debug|Win32
		{2F6F3CBA-BEB1-4C74-B483-B3E1FD991FF6}.Debug|x86.ActiveCfg = Debug|Win32
		{2F6F3CBA-BEB1-4C74-B483-B3E1FD991FF6}.Release|Any CPU.ActiveCfg = Release|Win32
		{2F6F3CBA-BEB1-4C74-B483-B3E1FD991FF6}.Release|Mixed Platforms.ActiveCfg = Release|Win32
		{2F6F3CBA-BEB1-4C74-B483-B3E1FD991FF6}.Release|Mixed Platforms.Build.0 = Release|Win32
		{2F6F3CBA-BEB1-4C74-B483-B3E1FD991FF6}.Release|Win32.ActiveCfg = Release|Win32
		{2F6F3CBA-BEB1-4C74-B483-B3E1FD991FF6}.Release|Win32.Build.0 = Release|Win32
		{2F6F3CBA-BEB1-4C74-B483-B3E1FD991FF6}.Release|x86.ActiveCfg = Release|Win32
		{F3C2ED90-7A65-4394-8B21-5631F67C8546}.Debug|Any CPU.ActiveCfg = Debug|Win32
		{F3C2ED90-7A65-4394-8B21-5631F67C8546}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
		{F3C2ED90-7A65-4394-8B21-5631F67C8546}.Debug|Mixed Platforms.Build.0 = Debug|Win32
		{F3C2ED90-7A65-4394-8B21-5631F67C8546}.Debug|Win32.ActiveCfg = Debug|Win32
		{F3C2ED90-7A65-4394-8B21-5631F67C8546}.Debug|Win32.Build.0 = Debug|Win32
		{F3C2ED90-7A65-4394-8B21-5631F67C8546}.Debug|x86.ActiveCfg = Debug|Win32
		{F3C2ED90-7A65-4394-8B21-5631F67C8546}.Release|Any CPU.ActiveCfg = Release|Win32
		{F3C2ED90-7A65-4394-8B21-5631F67C8546}.Release|Mixed Platforms.ActiveCfg = Release|Win32
		{F3C2ED90-7A65-4394-8B21-5631F67C8546}.Release|Mixed Platforms.Build.0 = Release|Win32
		{F3C2ED90-7A65-4394-8B21-5631F67C8546}.Release|Win32.ActiveCfg = Release|Win32
		{F3C2ED90-7A65-4394-8B21-5631F67C8546}.Release|Win32.Build.0 = Release|Win32
		{F3C2ED90-7A65-4394-8B21-5631F67C8546}.Release|x86.ActiveCfg = Release|Win32
		{87C29AA9-F692-4666-BA23-938127D4C84B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{87C29AA9-F692-4666-BA23-938127D4C84B}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{87C29AA9-F692-4666-BA23-938127D4C84B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
		{87C29AA9-F692-4666-BA23-938127D4C84B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
		{87C29AA9-F692-4666-BA23-938127D4C84B}.Debug|Win32.ActiveCfg = Debug|Any CPU
		{87C29AA9-F692-4666-BA23-938127D4C84B}.Debug|x86.ActiveCfg = Debug|Any CPU
		{87C29AA9-F692-4666-BA23-938127D4C84B}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{87C29AA9-F692-4666-BA23-938127D4C84B}.Release|Any CPU.Build.0 = Release|Any CPU
		{87C29AA9-F692-4666-BA23-938127D4C84B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
		{87C29AA9-F692-4666-BA23-938127D4C84B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
		{87C29AA9-F692-4666-BA23-938127D4C84B}.Release|Win32.ActiveCfg = Release|Any CPU
		{87C29AA9-F692-4666-BA23-938127D4C84B}.Release|x86.ActiveCfg = Release|Any CPU
		{446B93D8-A96C-491C-A266-38665098C154}.Debug|Any CPU.ActiveCfg = Debug|x86
		{446B93D8-A96C-491C-A266-38665098C154}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
		{446B93D8-A96C-491C-A266-38665098C154}.Debug|Mixed Platforms.Build.0 = Debug|x86
		{446B93D8-A96C-491C-A266-38665098C154}.Debug|Win32.ActiveCfg = Debug|x86
		{446B93D8-A96C-491C-A266-38665098C154}.Debug|x86.ActiveCfg = Debug|x86
		{446B93D8-A96C-491C-A266-38665098C154}.Debug|x86.Build.0 = Debug|x86
		{446B93D8-A96C-491C-A266-38665098C154}.Release|Any CPU.ActiveCfg = Release|x86
		{446B93D8-A96C-491C-A266-38665098C154}.Release|Mixed Platforms.ActiveCfg = Release|x86
		{446B93D8-A96C-491C-A266-38665098C154}.Release|Mixed Platforms.Build.0 = Release|x86
		{446B93D8-A96C-491C-A266-38665098C154}.Release|Win32.ActiveCfg = Release|x86
		{446B93D8-A96C-491C-A266-38665098C154}.Release|x86.ActiveCfg = Release|x86
		{446B93D8-A96C-491C-A266-38665098C154}.Release|x86.Build.0 = Release|x86
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

Mattias Högström
Architect Visma Software AB
Sweden Sweden
Mattias works at Visma, a leading Nordic ERP solution provider. He has good knowledge in C++/.Net development, test tool development, and debugging. His great passion is memory dump analysis. He likes giving talks and courses.
Follow on   Twitter

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141220.1 | Last Updated 27 Sep 2012
Article Copyright 2012 by Mattias Högström
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid