Assembler Injection -> Getting return value? menu

User Tag List

Results 1 to 12 of 12
  1. #1
    streppel's Avatar Active Member
    Reputation
    77
    Join Date
    Mar 2007
    Posts
    196
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Assembler Injection -> Getting return value?

    Hey all

    i tried searching for it but couldn't find an example so i'm asking here,sorry if this has been answered before.

    i'm using blackmagics Assembler injection to make the game run the functions i want.
    My question is, how to get the return value.
    in this case e.g. it's a thiscall function(i know that the classpointer is pushed in ecx etc) but how would i get the return value of the funtion e.g. in a variable then?

    thanks for your help

    Assembler Injection -> Getting return value?
  2. #2
    Cheatz0's Avatar Member
    Reputation
    14
    Join Date
    May 2009
    Posts
    36
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Move the the returnvalue-ptr to some free memory and read it oop? Never used BM for this though so I'm not sure.

  3. #3
    swooshy's Avatar Member
    Reputation
    2
    Join Date
    Dec 2009
    Posts
    24
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to return value is usually stored in the eax register after calling a function iirc.

    so

    Code:
    DWORD retvalue = 0;
    	__asm
    		{
    		CALL [somefunction]
    		MOV retvalue,eax
    		}
    I also never used bm but it should give you the idea
    Last edited by swooshy; 06-02-2011 at 05:06 PM.

  4. #4
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1511
    Join Date
    May 2008
    Posts
    2,432
    Thanks G/R
    81/333
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Store the EAX register in an address somewhere in the codecave. Then just read from that address.

  5. #5
    streppel's Avatar Active Member
    Reputation
    77
    Join Date
    Mar 2007
    Posts
    196
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    BM.Asm.AddLine("mov " + ret + " , eax");
    like this?
    then it tells me that the assembly failed. shouldn't mov simply copy over the value from eax to somewhere else(my adresse where i allocated memory)?

  6. #6
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by streppel View Post
    Code:
    BM.Asm.AddLine("mov " + ret + " , eax");
    like this?
    then it tells me that the assembly failed. shouldn't mov simply copy over the value from eax to somewhere else(my adresse where i allocated memory)?
    Code:
    BM.Asm.AddLine("mov [" + ret + "] , eax");
    should do it.

  7. #7
    asbest0s's Avatar Active Member CoreCoins Purchaser
    Reputation
    34
    Join Date
    Jan 2008
    Posts
    372
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Bananenbrot View Post
    Code:
    BM.Asm.AddLine("mov [" + ret + "] , eax");
    should do it.
    I'm not too familiar with Black Magic, but are you sure this is going to work?
    If that function takes a string as an argument then surely it's going to put the value of ret in (if it doesn't come up with a type error first), not the address.
    My guess is you need to do something like that, but correct me if I'm wrong
    Code:
    BM.Asm.AddLine("mov [" + (&ret).ToString("X") + "] , eax");

  8. #8
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  9. #9
    streppel's Avatar Active Member
    Reputation
    77
    Join Date
    Mar 2007
    Posts
    196
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you both,Macieks solution works fine

  10. #10
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by _Mike View Post
    Definitely the easiest solution, but unfortunately not always an option. It only returns a DWORD, even when running x64 threads, where you'll often want a DWORD64 back.

  11. #11
    !@^^@!'s Avatar Active Member
    Reputation
    23
    Join Date
    Feb 2007
    Posts
    155
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Cypher View Post
    Definitely the easiest solution, but unfortunately not always an option. It only returns a DWORD, even when running x64 threads, where you'll often want a DWORD64 back.
    *sad compatibility panda*
    Last edited by !@^^@!; 06-03-2011 at 07:24 PM.
    “Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.” - Rich Cook

  12. #12
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by !@^^@! View Post
    *sad compatibility panda*
    Yeah. My current solution is to use AsmJit to wrap functions I call in some generated code so I can pull out the full return value and the thread's last error code and store them in memory somewhere I can read it back. Though, I also use it to support a variable number of arguments, and a variable calling convention, so it's probably a bit overkill if the only thing you want is the return value... :/

Similar Threads

  1. Lua injection return value.
    By LogicWin in forum WoW Bots Questions & Requests
    Replies: 1
    Last Post: 03-28-2011, 09:45 AM
  2. [WoW][3.0.9] A way to get return values from Lua Functions
    By ramey in forum WoW Memory Editing
    Replies: 6
    Last Post: 03-22-2009, 10:09 PM
  3. Getting the return value of Lua_DoString()
    By Nesox in forum WoW Memory Editing
    Replies: 43
    Last Post: 01-15-2009, 06:06 AM
All times are GMT -5. The time now is 10:16 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search