Hello, I am learning how to make a trainer with c#. i have a problem trainer crashes the game.

I chose half life 2 game to try and I did the bullet cheat C.E. I found the pointers and created a trainer over memory.dll with c#. When I enter the game and open the cheat, the game closes without any errors.

I use the following code to writing

Code:
try
{
m.OpenProcess(Process.GetProcessesByName("hl2").FirstOrDefault().Id);
m.WriteMemory("server.dll+6F0890,56,F3D", "int", "666");//Ammo
}
catch
{
throw;
}