using System; using System.Threading.Tasks; namespace WhiteMagic.Examples; /// /// Main program for WhiteMagic examples /// Demonstrates all major features of the library /// class Program { static async Task Main(string[] args) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(@" ╔════════════════════════════════════════════════════════════════════════╗ ║ ║ ║ ████████╗██╗ ██╗██╗ ██████╗███████╗███████╗██╗ ██╗███████╗██╗ ║ ║ ╚══██╔══╝██║ ██║██║██╔════╝██╔════╝██╔════╝██║ ██║██╔════╝██║ ║ ║ ██║ ██║ ██║██║██║ ███████╗███████╗███████║█████╗ ██║ ║ ║ ██║ ██║ ██║██║██║ ╚════██║╚════██║██╔══██║██╔══╝ ██║ ║ ║ ██║ ╚██████╔╝██║╚██████╗███████║███████║██║ ██║███████╗███████╗║ ║ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝╚══════╝╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝║ ║ ║ ║ Process Introspection Library for .NET ║ ║ ║ ╚════════════════════════════════════════════════════════════════════════╝ "); Console.ResetColor(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(" Examples for Learning WhiteMagic API"); Console.WriteLine(" ─────────────────────────────────────"); Console.ResetColor(); while (true) { Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Select an example to run:"); Console.ResetColor(); Console.WriteLine(" 1. Basic Memory Operations (Read/Write, Arrays, Strings, Structs)"); Console.WriteLine(" 2. Pattern Scanning (Find patterns in memory)"); Console.WriteLine(" 3. Execution Models (RemoteThread, MainThreadPump, InProcess)"); Console.WriteLine(" 4. Function Hooking (Detours, Patches)"); Console.WriteLine(" 5. High-Level API (RemotePointer, RemoteModule, RemoteWindow, etc.)"); Console.WriteLine(" 6. Run All Examples"); Console.WriteLine(" 0. Exit"); Console.WriteLine(); Console.Write("Enter your choice (0-6): "); string? input = Console.ReadLine(); if (!int.TryParse(input, out int choice)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid input. Please enter a number between 0 and 6."); Console.ResetColor(); continue; } Console.WriteLine(); try { switch (choice) { case 1: BasicMemoryOperations.RunAll(); break; case 2: PatternScanning.RunAll(); break; case 3: await ExecutionModels.RunAll(); break; case 4: FunctionHooking.RunAll(); break; case 5: HighLevelAPI.RunAll(); break; case 6: // Run all examples sequentially BasicMemoryOperations.RunAll(); Console.WriteLine("\n" + new string('=', 70) + "\n"); await Task.Delay(500); PatternScanning.RunAll(); Console.WriteLine("\n" + new string('=', 70) + "\n"); await Task.Delay(500); await ExecutionModels.RunAll(); Console.WriteLine("\n" + new string('=', 70) + "\n"); await Task.Delay(500); FunctionHooking.RunAll(); Console.WriteLine("\n" + new string('=', 70) + "\n"); await Task.Delay(500); HighLevelAPI.RunAll(); break; case 0: Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Exiting WhiteMagic Examples. Thank you!"); Console.ResetColor(); return; default: Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid choice. Please enter a number between 0 and 6."); Console.ResetColor(); break; } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"\n✗ Error running example: {ex.Message}"); Console.WriteLine($" Stack trace: {ex.StackTrace}"); Console.ResetColor(); } if (choice != 0) { Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Press any key to continue..."); Console.ResetColor(); Console.ReadKey(); Console.Clear(); } } } }