title: c# basic memory reading
body: <p>okay i give up on strings , i dont know i dont get any value but thats ok for now.</p>
  
  <p>i want to read a simple 4byte int value. i searched in the memory for an exact value of 42 i took the first address.</p>
  
  <p>i already know that the array size has to be 4. but i get realy crazy values.</p>
  
  <p>like -12732139</p>
  
  <p>so i wrote a for loop that tells me the values which are stored inside the byte array</p>
  
  <pre><code>for (int j = 0; j &lt; bytes.Length; ++j ) {
                   svalue += "+" + bytes[j];
             }
  </code></pre>
  
  <p>i get realy strange numbers out of it </p>
  
  <pre><code>216 184 93 255 // these are stored inside the bytearray which should be 42 dec.
  </code></pre>
  
  <p>i guess something went really wrong ?</p>
  
  <p>i read those values with</p>
  
  <pre><code>ReadProcessMemory(readHandle, ((IntPtr)baseAddress + 0x000D3A10), bytes, (UIntPtr)4, ref rw);
  
  
  int test = BitConverter.ToInt32(new_bytes,0);
  </code></pre>
  
  <p>any ideas ?</p>
  
  <p>// OLD
  My full code:</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e) {
  
      Process[] iexp = Process.GetProcessesByName("iexplore");
      if (iexp.Length == 0) {
          listBox1.Items.Add("NOT FOUND");
      }
      Process internet = iexp[0];
      uint baseAddress = (uint)internet.MainModule.BaseAddress.ToInt32();
      IntPtr readHandle = OpenProcess(0x0010, false, (uint)internet.Id);
      byte[] bytes = new byte[24];
      uint rw = 0;
      uint size=sizeof(int);
  
      ReadProcessMemory(readHandle, ((IntPtr)baseAddress + 0x00581CCE), bytes, 
          (UIntPtr)24, ref rw);
      string sname= Encoding.ASCII.GetString(bytes);
      ReadProcessMemory(readHandle, (IntPtr)baseAddress + 0x00528744, bytes, 
          (UIntPtr)size, ref rw);
      int someNumber = BitConverter.ToInt32(bytes, 0);
  
      listBox1.Items.Add(sname);
      listBox1.Items.Add(someNumber);
  
  }
  </code></pre>