public MusicPlayer(MemoryModule mem, SfxChannelManager channelManager) { this.mem = mem; this.channelManager = channelManager; playingOnChanels = new bool[channelManager.Count]; }
public void CartData() { var mem = new MemoryModule(); mem.InitRam(); var storage = new PersistentDataStorage(mem); mem.AddMemoryListener(storage); Fix writeValNeg = (Fix)(-354.245); Fix writeValPos = (Fix)325.246; storage.CartData("test_slot_0"); storage.Dset(0, writeValNeg); storage.Dset(1, writeValPos); storage.Dset(63, writeValPos); storage.CartData("test_slot_1"); storage.Dset(0, writeValPos); Assert.AreNotEqual(writeValNeg, storage.Dget(0)); storage.CartData("test_slot_0"); Assert.AreEqual(writeValNeg, storage.Dget(0)); Assert.AreEqual(writeValPos, storage.Dget(1)); Assert.AreEqual(writeValPos, storage.Dget(63)); }
public ActionResult ChangeMemoryModule(MemoryModule p, HttpPostedFileBase NewImage, bool IsDeletePreviousImageFromServer = false, int page = 1, int pageSize = 20) { ViewBag.page = page; ViewBag.pageSize = pageSize; if (ModelState.IsValid) { if (NewImage != null) { if (NewImage.ContentLength <= 200000) { AddOrAddRemoveImageForCatalog(NewImage, IsDeletePreviousImageFromServer, p); } else { ModelState.AddModelError("NewImage", "Изображение должно быть меньше 200 Кб"); return(View(pcComponentsUnit.MemoryModules.GetElement(p.ID))); } } p.FullName = string.Format($"{p.Category} {p.Brand} {p.Model} {p.MemoryType} {p.OperatingFrequency}MHz {p.MemoryCapacity}GB ({p.ID})"); pcComponentsUnit.MemoryModules.Update(p); pcComponentsUnit.Save(); return(RedirectToActionPermanent("ComponentsCatalog", "Catalog", new { category = p.Category, page, pageSize })); } return(View(pcComponentsUnit.MemoryModules.GetElement(p.ID))); }
public void _Fx33_LD_B_Vx() { /* * Stores the BCD of vx in I, I+1, and I+2 of memory * 125: * Hex: 0x7D * BCD: 0001 0010 0101 */ var registers = new RegisterModule(); registers.SetGeneralValue(0, 0x7D); registers.SetI(0x123); var memory = new MemoryModule(Enumerable.Repeat((byte)0x0, 4096)); var emulator = CHIP8Factory.GetChip8(registers: registers, mem: memory); var instructions = new byte[] { 0xF0, //Store BCD of v0 in memory 0x33 }; emulator.LoadProgram(instructions); emulator.Tick += (e, a) => { emulator.Stop(); }; emulator.Start(); var startPoint = registers.GetI(); var hundreds = memory[startPoint]; startPoint++; var tens = memory[startPoint]; startPoint++; var ones = memory[startPoint]; Assert.Equal(0x1, hundreds); Assert.Equal(0x2, tens); Assert.Equal(0x5, ones); }
public MethodTests() { _memoryModule = new MemoryModule(); // Get the process id of the host process _hostProcessName = Process.GetCurrentProcess().ProcessName; }
public ExtensionTests() { _memoryModule = new MemoryModule(); // Get name of the host process _hostProcessName = Process.GetCurrentProcess().ProcessName; }
static TestClass() { MemoryModule memoryModule; memoryModule = MemoryModule.Create(IntPtr.Size == 8 ? Libflzma2_x64 : Libflzma2_x86); Compress = memoryModule.GetProcDelegate <CompressProc>("FL2_compressMt"); Decompress = memoryModule.GetProcDelegate <DecompressProc>("FL2_decompress"); IsError = memoryModule.GetProcDelegate <IsErrorProc>("FL2_isError"); }
public SfxChannelManager(MemoryModule memory, int channels) { this.channels = new SfxChannel[channels]; for (int i = 0; i < this.channels.Length; i++) { this.channels[i] = new SfxChannel(memory); } }
public void TestManualMap() { using (var injector = new Injector(_process.Id, _dllPath, InjectionMethod.ManualMap)) { using (var memoryModule = new MemoryModule(_process.Id)) { var firstTwoBytes = memoryModule.ReadVirtualMemory(injector.InjectDll(), 2); Assert.Equal(firstTwoBytes, new byte[] { 0x4D, 0x5A }); } } }
public Putty() { string libFileName = Environment.Is64BitProcess ? "SimpleRemote.Lib.putty64.dll.Compress" : "SimpleRemote.Lib.putty.dll.Compress"; _memoryModule = MemoryModule.Create(Common.GetCompressResBytes(libFileName)); Init = _memoryModule.GetProcDelegate<Putty_Init>("Putty_Init"); Create = _memoryModule.GetProcDelegate<Putty_Create>("Putty_Create"); GetError = _memoryModule.GetProcDelegate<Putty_GetError>("Putty_GetError"); SetCallback = _memoryModule.GetProcDelegate<Putty_SetCallback>("Putty_SetCallback"); Move = _memoryModule.GetProcDelegate<Putty_Move>("Putty_Move"); GetHwnd = _memoryModule.GetProcDelegate<Putty_GetHwnd>("Putty_GetHwnd"); Exit = _memoryModule.GetProcDelegate<Putty_Exit>("Putty_Exit"); Show = _memoryModule.GetProcDelegate<Putty_Show>("Putty_Show"); }
public void PeekPoke() { var mem = new MemoryModule(); mem.InitRam(); byte writeVal = (byte)Random.Range(1, 255); mem.Poke(MemoryModule.ADDR_GENERAL, writeVal); byte readVal = mem.Peek(MemoryModule.ADDR_GENERAL); Assert.AreEqual(writeVal, readVal); }
private void SetMemoryModuleResults(TextBox box, int input) { if (box == null || input < 0) { return; // Ensure input is not empty } var t = new MemoryModule(box, input); if (t.Stage <= 0 || t.Position == string.Empty) { return; } TextBlock outputLabel = null; switch (t.Stage) // each CASE is a stage { case 1: outputLabel = Mem_Lvl1_Output; break; case 2: outputLabel = Mem_Lvl2_Output; break; case 3: outputLabel = Mem_Lvl3_Output; break; case 4: outputLabel = Mem_Lvl4_Output; break; case 5: outputLabel = Mem_Lvl5_Output; break; default: MessageBox.Show("ERROR"); break; } outputLabel.Text = "I was Hit With - " + t.Number; t = null; //Debugger.Break(); }
public ScanResult PerformSignatureScan(byte[] pattern, string mask, ProcessModule module, bool codeOnly = true) { MemoryModule mmod = MemoryModule.FromMemory(this, module); byte[] buffer = new byte[4096]; int idx = 0; bool found = false; long start = mmod.ImageBase;// codeOnly ? mmod.BaseOfCode : mmod.ImageBase; long size = codeOnly ? mmod.SizeOfCode : mmod.MemorySize; while (true) { this.Position = start + idx; this.Position -= this.Position % 4; int length = this.Read(buffer, 0, (int)Math.Min(buffer.Length, size - idx)); for (int b = 0; b < buffer.Length - mask.Length; b++) { found = true; for (int i = 0; i < mask.Length; i++) { if (mask[i] != '?' && buffer[b + i] != pattern[i]) { found = false; break; } } if (found) { byte[] data = new byte[mask.Length]; Array.Copy(buffer, b, data, 0, mask.Length); return(ScanResult.Succeeded(start + idx + b, data)); } } if (length - mask.Length == 0) { break; } idx += length - mask.Length; if (this.Position >= start + size) { break; } } return(ScanResult.Failed()); }
public void MemSet() { var mem = new MemoryModule(); mem.InitRam(); mem.MemSet(MemoryModule.ADDR_GENERAL, 128, 64); for (int i = 0; i < 64; i++) { byte val = mem.Peek(MemoryModule.ADDR_GENERAL + i); Assert.AreEqual(128, val); } }
protected static unsafe void Process(IntPtr settings) { if (_Process == null) { #if USE_MEMORY_MODULE byte[] data = QChkUI.Properties.Resources.QCHK; mem = new MemoryModule(data); _Process = (ProcessFunc)mem.GetDelegateFromFuncName(0, typeof(ProcessFunc)); #else IntPtr pDll = LoadLibrary("QCHK.dll"); IntPtr pAddressOfFunctionToCall0 = GetProcAddress(pDll, (IntPtr)1); _Process = (ProcessFunc)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall0, typeof(ProcessFunc)); #endif } _Process(settings); }
protected static unsafe void Process(IntPtr settings) { if (_Process == null) { #if USE_MEMORY_MODULE byte[] data = TranslatorUI.Properties.Resources.TranslateLib; mem = new MemoryModule(data); _Process = (ProcessFunc)mem.GetDelegateFromFuncName(0, typeof(ProcessFunc)); #else IntPtr pDll = LoadLibrary("C:\\Users\\Tom\\Desktop\\Documents\\Visual Studio 2015\\Projects\\TranslateLib\\Debug\\TranslateLib.dll"); IntPtr pAddressOfFunctionToCall0 = GetProcAddress(pDll, (IntPtr)1); _Process = (ProcessFunc)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall0, typeof(ProcessFunc)); #endif } _Process(settings); }
public int NumberOfStepsUntilDuplicateState(int[] initialBlocks) { MemoryModule memoryModule = new MemoryModule(initialBlocks); int steps = 0; bool noDuplicateState = true; while (noDuplicateState) { steps++; memoryModule.Reallocate(); noDuplicateState = memoryModule.NoDuplicateState(); } return(steps); }
public MemoryModule GetMyModule() { Dictionary <string, IMemoryModule> .Enumerator modules = GameSharpProcess.Instance.Modules.GetEnumerator(); while (modules.MoveNext()) { MemoryModule module = modules.Current.Value as MemoryModule; // Address has to be between the start address of the module and the end address of the module. if (Address.ToInt64() > module.BaseAddress.ToInt64() && Address.ToInt64() < module.BaseAddress.ToInt64() + module.ModuleMemorySize) { return(module); } } return(null); }
private void InitializeAntiCheatHook() { byte[] bytes = HookPtr.GetReturnToPtr(); MemoryModule module = TargetFuncPtr.GetMyModule(); if (module == null) { throw new NullReferenceException("Cannot find a module which belongs to the specified pointer."); } MemoryAddress codeCave = module.FindCodeCaveInModule((uint)bytes.Length); CodeCavePatch = new MemoryPatch(codeCave, bytes); byte[] retToCodeCave = CodeCavePatch.PatchAddress.GetReturnToPtr(); HookPatch = new MemoryPatch(TargetFuncPtr, retToCodeCave); }
public int NumberOfStepsBetweenFirstDuplicate(int[] initialBlocks) { MemoryModule memoryModule = new MemoryModule(initialBlocks); int steps = 0; bool noDuplicateState = true; while (noDuplicateState) { steps++; memoryModule.Reallocate(); noDuplicateState = memoryModule.NoDuplicateState(); } int stepOfFirstDuplicate = memoryModule.IndexOfFirstDuplicate(); return(steps - (stepOfFirstDuplicate + 1)); }
public void Peek4Poke4() { var mem = new MemoryModule(); mem.InitRam(); Fix writeValNeg = (Fix)(-354.245); Fix writeValPos = (Fix)325.246; mem.Poke4(MemoryModule.ADDR_GENERAL, writeValNeg); mem.Poke4(MemoryModule.ADDR_GENERAL + 4, writeValPos); Fix readValNeg = mem.Peek4(MemoryModule.ADDR_GENERAL); Fix readValPos = mem.Peek4(MemoryModule.ADDR_GENERAL + 4); Assert.AreEqual(writeValNeg, readValNeg); Assert.AreEqual(writeValPos, readValPos); }
public void Peek2Poke2() { var mem = new MemoryModule(); mem.InitRam(); short writeValNeg = -32765; short writeValPos = 32765; mem.Poke2(MemoryModule.ADDR_GENERAL, writeValNeg); mem.Poke2(MemoryModule.ADDR_GENERAL + 2, writeValPos); short readValNeg = mem.Peek2(MemoryModule.ADDR_GENERAL); short readValPos = mem.Peek2(MemoryModule.ADDR_GENERAL + 2); Assert.AreEqual(writeValNeg, readValNeg); Assert.AreEqual(writeValPos, readValPos); }
// Mutators public void SetClient(int procId) { try { Process client = Process.GetProcessById(procId); _mem = new MemoryModule(); GameProcess = client; BaseAddress = client.MainModule.BaseAddress; InitializeClient(); } catch (Exception b) { // } }
void BtnReadFileData_Click(object sender, EventArgs e) { try { string mapName = "_Text"; if (null == _memoryModule) { _memoryModule = new MemoryModule <byte>(mapName, 1024); } byte[] data = _memoryModule.GetAll(); this.m_view.TxtRead.Text = System.Text.Encoding.Default.GetString(data).Trim(); } catch (Exception) { throw; } }
public SafeFunction() { Delegate @delegate = ToCallDelegate(); MemoryAddress originalFuncPtr = @delegate.ToFunctionPtr(); MemoryModule module = originalFuncPtr.GetMyModule(); List <byte> bytes = new List <byte>(); bytes.AddRange(originalFuncPtr.GetReturnToPtr()); IMemoryAddress codeCave = module.FindCodeCaveInModule((uint)bytes.Count); codeCave.Write(bytes.ToArray()); Type typeOfDelegate = @delegate.GetType(); SafeFunctionDelegate = Marshal.GetDelegateForFunctionPointer(codeCave.Address, typeOfDelegate); }
internal Properties(Process process, string dllPath) { DllPath = dllPath; // Determine if the process is running under Wow64 Native.IsWow64Process(process.SafeHandle, out IsWow64); MemoryModule = new MemoryModule(); // Get the pe headers of the dll PeHeaders = new PeFile(dllPath); ProcessId = process.Id; // Open a handle to the process ProcessHandle = process.SafeHandle; }
public ExternalCommunicationBuffer() : base(MAGIC_NUMBER_BYTE_LENGTH + HEADER_BYTE_LENGTH + DATA_BYTE_LENGTH, MAGIC_NUMBER_BYTE_LENGTH) { this.memoryModule = new MemoryModule("TS3"); //The buffer tends to be after this address, so use this for quicker searching. Not guaranteed. To be replaced with actual pointer mapping later on //List<IntPtr> addresses = memoryModule.PatternScan(new IntPtr(0x20000000), BUFFER_MAGIC_NUMBERS).ToList(); //if (addresses.Count != 1) { // //Error handle??? //} //this.bufferAddress = addresses.ElementAt(0); //Console.WriteLine("Buffer Address: {0:x}", bufferAddress.ToInt32()); //From Cheat Engine investigation int baseAddress = 0x00400000; int baseOffset = 0x00E1D89C; //Using the path from cheat engine, navigate the pointers to our buffer (hopefully) List <int> offsets = new List <int> { 0x18, 0x24, 0x1e0, 0x1c, 0x1c, 0x1c, 0x18, 0x1c, 0x10 }; int address = baseAddress + baseOffset; foreach (int offset in offsets) { address = BitConverter.ToInt32(memoryModule.ReadVirtualMemory(new IntPtr(address), 4), 0) + offset; } Console.WriteLine("Buffer Address: {0:x}", address); bufferAddress = new IntPtr(address); //Make sure that the pointer has actually given us the buffer byte[] toCompare = memoryModule.ReadVirtualMemory(bufferAddress, BUFFER_MAGIC_NUMBERS.Length); bool equal = Enumerable.SequenceEqual(BUFFER_MAGIC_NUMBERS, toCompare); if (!equal) { Console.WriteLine("Big boi error time! The bytes at the found address are not correct!"); System.Environment.Exit(-1); } }
void BtnWriteFileData_Click(object sender, EventArgs e) { try { string mapName = "_Text"; if (null == _memoryModule) { _memoryModule = new MemoryModule <byte>(mapName, 1024); } if (string.Empty.Equals(this.m_view.TxtWrite.Text)) { return; } byte[] byteArray = System.Text.Encoding.Default.GetBytes(this.m_view.TxtWrite.Text); _memoryModule.SetPosition(0, byteArray); } catch (Exception) { throw; } }
protected void Update_Elapsed2(object sender, ElapsedEventArgs e) { Lock.WaitOne(); if (!IsFirstScanComplete) { IsFirstScanComplete = true; // Physical Memory searcher = new ManagementObjectSearcher("select * from Win32_PhysicalMemory"); // Scrape & Update foreach (ManagementObject share in searcher.Get()) { MemoryModule temp = new MemoryModule(); if (!((string)share["Manufacturer"]).Contains("Manufacturer")) { Utils.Try(() => temp.Manufaturer = (string)share["Manufacturer"]); } if (!((string)share["SerialNumber"]).Contains("SerNum")) { Utils.Try(() => temp.PartNumber = (string)share["SerialNumber"]); } Utils.Try(() => temp.Capacity = (float)(UInt64)share["Capacity"] / (1024 * 1024)); TotalCapacity += temp.Capacity; // Get total RAM Utils.Try(() => temp.SetFormFactor((int)(ushort)share["FormFactor"])); Utils.Try(() => temp.Speed = (int)(uint)share["Speed"]); MemoryModules.Add(temp); } // End outer management loop } // End static properties // Scrape Dynamic Info foreach (var hardware in computerHardware.Hardware) { hardware.Update(); foreach (var sensor in hardware.Sensors) { if (sensor.SensorType == SensorType.Load && sensor.Value != null) { TotalPercentUtilization = (double)sensor.Value; // 40.5 } else if (sensor.SensorType == SensorType.Data) { if (sensor.Name.Equals("Used Memory") && sensor.Value != null) { TotalAmountInUse = (float)sensor.Value; // 3.2 } else if (sensor.Name.Equals("Available Memory") && sensor.Value != null) { TotalAmountAvailable = (float)sensor.Value; // 4.7 } } } } // Page File searcher = new ManagementObjectSearcher("select * from Win32_OperatingSystem"); // Scrape & Update foreach (ManagementObject share in searcher.Get()) { Utils.Try(() => PageCapacity = (float)(UInt64)share["SizeStoredInPagingFiles"] / 1024); Utils.Try(() => PageCapacityRemaining = (float)(UInt64)share["FreeSpaceInPagingFiles"] / 1024); } // Win32_PerRawData_PerfOS_Memory - Committed, Cached, Pagepool, NonPagepool searcher = new ManagementObjectSearcher("select * from Win32_PerfRawData_PerfOS_Memory"); // Scrape & Update double committedGb = 0; double commitLimitGb = 0; Cached = 0; foreach (ManagementObject share in searcher.Get()) { Utils.Try(() => Cached += (float)(UInt64)share["ModifiedPageListBytes"]); Utils.Try(() => Cached += (float)(UInt64)share["StandbyCacheCoreBytes"]); Utils.Try(() => Cached += (float)(UInt64)share["StandbyCacheNormalPriorityBytes"]); Utils.Try(() => Cached += (float)(UInt64)share["StandbyCacheReserveBytes"]); Utils.Try(() => committedGb = (double)(UInt64)share["CommittedBytes"] / (1024 * 1024 * 1024)); Utils.Try(() => commitLimitGb = (double)(UInt64)share["CommitLimit"] / (1024 * 1024 * 1024)); Utils.Try(() => PagedPool = (float)(UInt64)share["PoolPagedBytes"] / (1024 * 1024)); Utils.Try(() => NonPagedPool = (float)(UInt64)share["PoolNonpagedBytes"] / (1024 * 1024)); } Commited = committedGb.ToString("#.##") + "/" + commitLimitGb.ToString("#.##") + " Gb"; Cached /= (1024 * 1024 * 1024); //Gb Lock.Release(); Update.Start(); }
internal RtlCreateUserThread() { _memoryModule = new MemoryModule(); }
internal CreateRemoteThread() { _memoryModule = new MemoryModule(); }
public void Memory(Action<MemoryModule> configure) { var m = new MemoryModule(); configure(m); Advanced.RegisterModule(m); }