-
Notifications
You must be signed in to change notification settings - Fork 170
Add missing listings #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add missing listings #283
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a0ed09d
Add listing 1.20
BenjaminMichaelis cea5d1e
save unicode symbol
BenjaminMichaelis 5eeab38
Make second 14.04 file placeholder
BenjaminMichaelis 8214d9c
Make second 17.07 listing a placeholder
BenjaminMichaelis c320450
Update listing 18.11 (merge files and minor changes)
BenjaminMichaelis 80f1dd6
Add missing listings to Chapter 23
BenjaminMichaelis 12f700d
Update src/Chapter23/Listing23.06.Win32ErrorHandling.cs
BenjaminMichaelis d07d403
Update src/Chapter23/Listing23.07.ManagedResourcesUsingSafeHandle.cs
BenjaminMichaelis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter01.Listing01_20 | ||
| { | ||
| /* | ||
| #region INCLUDE | ||
| .assembly extern System.Runtime | ||
| { | ||
| .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) | ||
| .ver 4:2:0:1 | ||
| } | ||
|
|
||
|
|
||
| .assembly extern System.Console | ||
| { | ||
| .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) | ||
| .ver 4:1:0:1 | ||
| } | ||
|
|
||
|
|
||
| .assembly 'HelloWorld' | ||
| { | ||
| .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = (01 00 08 00 00 00 00 00 ) | ||
| .custom instance void [System.Runtime]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = (01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) | ||
| .custom instance void [System.Runtime]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = (01 00 18 2E 4E 45 54 43 6F 72 65 41 70 70 2C 56 65 72 73 69 6F 6E 3D 76 33 2E 30 01 00 54 0E 14 46 72 61 6D 65 77 6F 72 6B 44 69 73 70 6C 61 79 4E 61 6D 65 00 ) | ||
| .custom instance void [System.Runtime]System.Reflection.AssemblyCompanyAttribute::.ctor(string) = (01 00 0A 48 65 6C 6C 6F 57 6F 72 6C 64 00 00 ) | ||
| .custom instance void [System.Runtime]System.Reflection.AssemblyConfigurationAttribute::.ctor(string) = (01 00 05 44 65 62 75 67 00 00 ) | ||
| .custom instance void [System.Runtime]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = (01 00 07 31 2E 30 2E 30 2E 30 00 00 ) | ||
| .custom instance void [System.Runtime]System.Reflection.AssemblyInformationalVersionAttribute::.ctor(string) = (01 00 05 31 2E 30 2E 30 00 00 ) | ||
| .custom instance void [System.Runtime]System.Reflection.AssemblyProductAttribute::.ctor(string) = (01 00 0A 48 65 6C 6C 6F 57 6F 72 6C 64 00 00 ) | ||
| .custom instance void [System.Runtime]System.Reflection.AssemblyTitleAttribute::.ctor(string) = (01 00 0A 48 65 6C 6C 6F 57 6F 72 6C 64 00 00 ) | ||
| .hash algorithm 0x00008004 | ||
| .ver 1:0:0:0 | ||
| } | ||
|
|
||
|
|
||
| .module 'HelloWorld.dll' | ||
| // MVID: {05b2d1a7-c150-4f20-bd96-c065e4f97a31} | ||
| .imagebase 0x00400000 | ||
| .file alignment 0x00000200 | ||
| .stackreserve 0x00100000 | ||
| .subsystem 0x0003 // WindowsCui | ||
| .corflags 0x00000001 // ILOnly | ||
|
|
||
|
|
||
| .class private auto ansi beforefieldinit HelloWorld.Program extends[System.Runtime] System.Object | ||
| { | ||
|
|
||
|
|
||
| .method private hidebysig static void Main(string[] args) cil managed | ||
| { | ||
| .entrypoint | ||
| // Code size 13 | ||
| .maxstack 8 | ||
| IL_0000: nop | ||
| IL_0001: ldstr "Hello. My name is Inigo Montoya." | ||
| IL_0006: call void | ||
| ↪ System.Console]System.Console::WriteLine(string) | ||
| IL_000b: nop | ||
| IL_000c: ret | ||
| } // End of method System.Void HelloWorld.Program::Main(System.String[]) | ||
|
|
||
|
|
||
| .method public hidebysig specialname rtspecialname instance void .ctor() cil managed | ||
| { | ||
| // Code size 8 | ||
| .maxstack 8 | ||
| IL_0000: ldarg.0 | ||
| IL_0001: call instance void [System.Runtime] | ||
| System.Object::.ctor() | ||
| IL_0006: nop | ||
| IL_0007: ret | ||
| } // End of method System.Void HelloWorld.Program::.ctor() | ||
| } // End of class HelloWorld.Program | ||
| #endregion INCLUDE | ||
| */ | ||
| } |
File renamed without changes.
File renamed without changes.
17 changes: 0 additions & 17 deletions
17
src/Chapter18/18.11.SpecifyingAReturnAttribute.DescriptionAttribute.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,27 @@ | ||
| using System; | ||
|
|
||
| namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_11 | ||
| { | ||
| public class Program | ||
| { | ||
| [return: Description( | ||
| "Returns true if the object is in a valid state.")] | ||
| public bool IsValid() | ||
| public static bool IsValid() | ||
| { | ||
| // ... | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| public class DescriptionAttribute : Attribute | ||
| { | ||
| // TODO: Update listing in Manuscript | ||
| private readonly string _Description; | ||
| public string Description { get { return _Description; } } | ||
|
|
||
| public DescriptionAttribute(string description) | ||
| { | ||
| this._Description = description; | ||
| } | ||
| } | ||
| } | ||
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter23.Listing23_01 | ||
| { | ||
| #region INCLUDE | ||
| using System; | ||
| using System.Runtime.InteropServices; | ||
| public class VirtualMemoryManager | ||
| { | ||
| [DllImport("kernel32.dll", EntryPoint = "GetCurrentProcess")] | ||
| internal static extern IntPtr GetCurrentProcessHandle(); | ||
| } | ||
| #endregion INCLUDE | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter23.Listing23_02 | ||
| { | ||
| #region INCLUDE | ||
| using System; | ||
| using System.Runtime.InteropServices; | ||
| public class VirtualMemoryManager | ||
| { | ||
| [DllImport("kernel32.dll")] | ||
| internal static extern IntPtr GetCurrentProcess(); | ||
|
|
||
| [DllImport("kernel32.dll", SetLastError = true)] | ||
| private static extern IntPtr VirtualAllocEx( | ||
| IntPtr hProcess, | ||
| IntPtr lpAddress, | ||
| IntPtr dwSize, | ||
| AllocationType flAllocationType, | ||
| uint flProtect); | ||
| } | ||
| #endregion INCLUDE | ||
| } |
14 changes: 14 additions & 0 deletions
14
src/Chapter23/Listing23.03.DeclaringTheVirtualAllocExAPI.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter23.Listing23_03 | ||
| { | ||
| #region INCLUDE | ||
| public class VirtualMemoryManager | ||
| { | ||
| // ... | ||
| [DllImport("kernel32.dll", SetLastError = true)] | ||
| static extern bool VirtualProtectEx( | ||
| IntPtr hProcess, IntPtr lpAddress, | ||
| IntPtr dwSize, uint flNewProtect, | ||
| ref uint lpflOldProtect); | ||
| } | ||
| #endregion INCLUDE | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/Chapter23/Listing23.04.UsingrefAndoutRatherThanPointers.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter23.Listing23_04 | ||
| { | ||
| #region INCLUDE | ||
| using System; | ||
| using System.Runtime.InteropServices; | ||
| public class VirtualMemoryManager | ||
| { | ||
| [DllImport("kernel32.dll", EntryPoint = "GetCurrentProcess")] | ||
| internal static extern IntPtr GetCurrentProcessHandle(); | ||
| } | ||
| #endregion INCLUDE | ||
| } |
24 changes: 24 additions & 0 deletions
24
src/Chapter23/Listing23.05.DeclaringTypesFromUnmanagedStructs.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter23.Listing23_05 | ||
| { | ||
| #region INCLUDE | ||
| [StructLayout(LayoutKind.Sequential)] | ||
| struct ColorRef | ||
| { | ||
| public byte Red; | ||
| public byte Green; | ||
| public byte Blue; | ||
| // Turn off the warning about not accessing Unused | ||
| #pragma warning disable 414 | ||
| private byte Unused; | ||
| #pragma warning restore 414 | ||
|
|
||
| public ColorRef(byte red, byte green, byte blue) | ||
| { | ||
| Blue = blue; | ||
| Green = green; | ||
| Red = red; | ||
| Unused = 0; | ||
| } | ||
| } | ||
| #endregion INCLUDE | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| using System; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter23.Listing23_06 | ||
| { | ||
| #region INCLUDE | ||
| public class VirtualMemoryManager | ||
| { | ||
| [DllImport("kernel32.dll", SetLastError = true)] | ||
| private static extern IntPtr VirtualAllocEx( | ||
| IntPtr hProcess, | ||
| IntPtr lpAddress, | ||
| IntPtr dwSize, | ||
| AllocationType flAllocationType, | ||
| uint flProtect); | ||
|
|
||
| // ... | ||
| [DllImport("kernel32.dll", SetLastError = true)] | ||
| static extern bool VirtualProtectEx( | ||
| IntPtr hProcess, IntPtr lpAddress, | ||
| IntPtr dwSize, uint flNewProtect, | ||
| ref uint lpflOldProtect); | ||
|
|
||
| [Flags] | ||
| private enum AllocationType : uint | ||
| { | ||
| #region EXCLUDE | ||
| Reserve, | ||
| Commit | ||
| #endregion EXCLUDE | ||
| } | ||
|
|
||
| [Flags] | ||
| private enum ProtectionOptions | ||
| { | ||
| #region EXCLUDE | ||
| PageExecuteReadWrite | ||
| #endregion EXCLUDE | ||
| } | ||
|
|
||
| [Flags] | ||
| private enum MemoryFreeType | ||
| { | ||
| // ... | ||
| } | ||
|
|
||
| public static IntPtr AllocExecutionBlock( | ||
| int size, IntPtr hProcess) | ||
| { | ||
| IntPtr codeBytesPtr; | ||
| codeBytesPtr = VirtualAllocEx( | ||
| hProcess, IntPtr.Zero, | ||
| (IntPtr)size, | ||
| AllocationType.Reserve | AllocationType.Commit, | ||
| (uint)ProtectionOptions.PageExecuteReadWrite); | ||
|
|
||
| if (codeBytesPtr == IntPtr.Zero) | ||
| { | ||
| throw new System.ComponentModel.Win32Exception(); | ||
| } | ||
|
|
||
| uint lpflOldProtect = 0; | ||
| if (!VirtualProtectEx( | ||
| hProcess, codeBytesPtr, | ||
| (IntPtr)size, | ||
| (uint)ProtectionOptions.PageExecuteReadWrite, | ||
| ref lpflOldProtect)) | ||
| { | ||
| throw new System.ComponentModel.Win32Exception(); | ||
| } | ||
| return codeBytesPtr; | ||
| } | ||
|
|
||
| public static IntPtr AllocExecutionBlock(int size) | ||
| { | ||
| return AllocExecutionBlock( | ||
| size, GetCurrentProcessHandle()); | ||
| } | ||
|
|
||
| #region EXCLUDE | ||
| public static IntPtr GetCurrentProcessHandle() | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
| #endregion EXCLUDE | ||
| } | ||
| #endregion INCLUDE | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.