private static void AssertNull(ScanResult scanResult)
 {
     if (scanResult == null)
     {
         throw new Exception();
     }
 }
        private static void ScanAndPatch(ProcessMemoryScanner scanner, ScanResult scanResult)
        {
            try
            {
                AssertNull(scanResult);

                //Find KW_ADD keyword
                ScanResult patchScanResult = scanResult.ScanNext(KW_ADD);
                AssertNull(patchScanResult);

                //Change keyword KW_ADD value onto KW_DCT value
                uint patchResult = scanner.PatchMemory(patchScanResult, KW_DCT);
                AssertPatchMemoryResult(patchResult, (uint) KW_DCT.Length);

                //Looking for 'showAttackClaim' method call
                patchScanResult = scanResult.ScanNext(KD_SHOW_ATTACK_CLAIM);
                AssertNull(patchScanResult);

                //Call 'dct' method instead 'showAttackClaim' and change current procedure to method
                patchResult = scanner.PatchMemory(patchScanResult, KD_DCT);
                AssertPatchMemoryResult(patchResult, (uint) KD_DCT.Length);
            } catch {}
        }
 private void AssertScanResult(ScanResult result)
 {
     if (result == null)
     {
         throw new Exception("Scan result is null-reference");
     }
 }
 public uint PatchMemory(ScanResult result, object obj, uint length)
 {
     AssertScanResult(result);
     return PatchMemory(result.CurrentAddress, obj, length);
 }
 public ScanResult ScanNext(ScanResult result, object obj)
 {
     return result != null
                ? Scan(result.CurrentAddress + result.DataLength,
                       result.EndAddress,
                       obj)
                : null;
 }