title: C++ ASM get address of MOV
body: <p>I have the following line in ASM</p>
  
  <pre><code>_:004F73BB C6 83 54 41 03 00 01     mov  byte ptr [ebx+34154h], 1
  </code></pre>
  
  <p>In c++ i need to return the value of 34154h as an address ( 0x34154 )</p>
  
  <p>Im hoping this can be done like so:</p>
  
  <pre><code>void getADR(BYTE *ptr1){//something like this?
       __asm{//i don't know how to call this at 004F73BB
            mov [ptr1], ebx
            mov  byte ptr [ebx+34154h], 1
       }
       // return ((BYTE)0x004F73BB - ptr1)
  }
  </code></pre>
  
  <p>_____MY Logger____
  This is my address logger that gets the ASM line 0x004F73BB
  The playerpointer and server pointers are both easy to get because the byte patters point to a MOV and MOV returns the pointer of itself.</p>
  
  <pre><code>DWORD FindPattern(DWORD dwAddress, DWORD dwLen, BYTE *bMask, char * szMask)
  {
      for (DWORD i = 0; i &lt; dwLen; i++)
      if (Match((BYTE*)(dwAddress + i), bMask, szMask))
          return (DWORD)(dwAddress + i);
  
      return 0;
  }
  void SearchPatterns(void)
  {
      while (true){
  
          add_log("ADR_PlayerPointer", "\xA4\xA2\xAE\x00", "xxx?", "A4 A2 AE 00, xxx?");
          add_log("ADR_ServerPointer", "\x48\x92\xAE\x00", "xxx?", "A1 48 92 AE 00, xxx?");
          add_log("OFS_5thSlot", "\x75\x09\xC6\x83\x54\x41\x03\x00\x01", "xxxxxxx?x", "75 09 C6 83 54 41 03 00 01, xxxxxxx?x");
  
          ExitProcess(0);
      }
  }
  
  
  
  BOOL WINAPI DllMain(HMODULE hDll, DWORD dwReason, LPVOID lpReserved)
  {
      //DisableThreadLibraryCalls(hDll);
      if (dwReason == DLL_PROCESS_ATTACH)
      {
          logging(hDll);
          CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)SearchPatterns, NULL, NULL, NULL);
      }
      return TRUE;
  }
  </code></pre>
  
  <p>If you need more information leave a comment.</p>