title: How to find an address by a hex value in string format?
body: <p>I have a <code>int key1 = -1466731422;</code> which returns me the hex value <code>62 74 93 A8</code> from the .exe when I search for it in a hex editor.<br>
  What I'm trying to do is to overwrite a <code>newKey1</code>, which can be choosen by the user, over that <code>key1</code>.<br>
  Supposing we want to overwrite that <code>key1</code> for <code>int newKey1 = -1566731422</code>, what I did so far is:</p>
  
  <pre><code>private void btnGravar_Click(object sender, EventArgs e)
  {
      FixHex(key1, newKey1); //transform the int key in hex string
  
      br = new BinaryReader(File.OpenRead(element.FileName));            
      try
      {                
          for (long i = 0; i &lt;= br.BaseStream.Length; i++)
          {
              if (br.BaseStream.ReadByte() == (byte)Convert.ToInt32(key1, 16))
              {
                  progressBar.Value = progressBar.Maximum;
                  br.Close();
                  bw = new BinaryWriter(File.OpenWrite(element.FileName));
                  bw.BaseStream.Position = i;
                  bw.Write(newKey1);
                  bw.Close();
  
                  MessageBox.Show("Key updated", "Success");
                  break;
              }
              else
              {
                  progressBar.Value += 1;
              }
          }
      }
      catch (Exception ex)
      {
          MessageBox.Show(ex.ToString());
      }
  }        
  </code></pre>
  
  <p>It didn't work, tho. My <code>for</code> loop doesn't find a match, so what I think it will solve it's a method to find the address by the <code>int key</code> (since in a hex editor I can do it) OR by a hex in string format.</p>