[General] __thiscall method returning list/vector menu

User Tag List

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

    [General] __thiscall method returning list/vector

    Hey all
    it's me again ^^

    my question is how to get the list/vector that is returned by a function.
    According to this thread ( http://www.mmowned.com/forums/world-...n32-mingw.html ) all classes and structures are returned in memory, into an additional pointer that was pushed on the stack too.
    So in ida my function has something like this signature:
    public class std::vector <class whatever,class std:allocator<whatever *>> _thicall MyClass::MyMethod(void);

    for the thiscall i'm moving a pointer to the instance of the class MyClass in ecx.
    now normally i'd just do a "call "+MethodAdresse, but as i said before, according to the other thread, i'D have to pass another parameter
    so "mov eax, "+SomeAllocatedMemoryAdresseThatIsBigEnough
    looks good now,not?

    the problem is,that it does not work this way either. both ways(with passing a pointer to allocated memory and without doing so) cause a client crash that i can't seem ti find around.

    i'm using RivaLfr's method of hooking Endscene to execute my code in the main thread and all other functions like assisting work fine this way, so i guess that this is not the problem.

    thanks for your help again
    streppel

    [General] __thiscall method returning list/vector
  2. #2
    LordJZ's Avatar Member
    Reputation
    11
    Join Date
    Jan 2009
    Posts
    28
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try pushing the pointer onto stack like

    push SomeAllocatedMemoryAdresseThatIsBigEnough
    mov ecx, ptrThis
    call func

  3. #3
    streppel's Avatar Active Member
    Reputation
    78
    Join Date
    Mar 2007
    Posts
    196
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ofc i did push it on the stack,afterwards wrote my adresse to eax and did a "call eax"
    Code:
                string[] asm = new string[]
                {
                    "mov eax, "+r1,
                    "push eax",
                    "mov eax, "+(GetModuleAdresse("Module.dll")+0x0FF5E7),
                    "mov ecx, "+GetInstance(),
                    "call eax",
                    "retn"
                };
    r1 is the adresse to my allocated memory,pushed on the stack. eax contains the adress of the function i want to call and ecx the instance of the class. i can't see any mistake there,it should be working,shouldn't it?

  4. #4
    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)
    Did you check the signature in ida?

    EDIT: Ok, i mean did you verify how the parameters are pushed onto the stack?
    Last edited by Bananenbrot; 06-19-2011 at 09:14 AM.

  5. #5
    streppel's Avatar Active Member
    Reputation
    78
    Join Date
    Mar 2007
    Posts
    196
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Bananenbrot View Post
    Did you check the signature in ida?

    EDIT: Ok, i mean did you verify how the parameters are pushed onto the stack?
    Code:
    int __thiscall MyClass__MyMethod(void *this)
    {
      int v1; // eax@1
      int result; // eax@2
    this is what idas decompiler shows me
    v1 is being overwritten in the next line while result is being set to the result of some subroutine and returned afterwards.

    i also tryed to create 2 codecaves and push the adresses to them on the stack(as i saw above that there is a eax@1 and eax@2 what i interpreted as what gets popped from the stack. is that right at all?) but it didn't work either :/

  6. #6
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why don't you just take a look at how other functions call the function? Or what the function does?
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  7. #7
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please make something clear:
    Are you calling

    - gcc created code from msvc created code ?
    - msvc created code from gcc created code ?
    - gcc created code from gcc created code ?
    - msvc created code from msvc created code ?

    i'm using RivaLfr's method of hooking Endscene to execute my code in the main thread and all other functions like assisting work fine this way, so i guess that this is not the problem.
    This makes me assume that you run your code on a Windows box.
    In the case you are compiling with mingw(gcc), just get msvc ... the better compiler for Windows.
    If you are already using VS ... why the heck are you reading instruction for doing that call with gcc?
    Last edited by flo8464; 06-20-2011 at 03:38 AM.
    Hey, it compiles! Ship it!

  8. #8
    streppel's Avatar Active Member
    Reputation
    78
    Join Date
    Mar 2007
    Posts
    196
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm calling msvc created code from msvc created code
    and the other thread is general about compilers and how they handle their stuff, so i just used it to get my information on where and how something is renturned

  9. #9
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, then you might be able to to do it like that:

    template<typename T>
    std::vector<T> MyClass__MyMethod(void *this)
    {
    typedef std::vector<T>* (*fPtr __thiscall)(void*);
    std::vector<T>* result = reinterpret_cast<fPtr>(INSERT_ADDRESS)(this);
    return std::vector<T>(result);
    }
    This only works if the original code doesn't allocate memory for the vector<> on the stack and if your vector-implementation is binary-compatible with the vector used by the application you're reversing.
    But well, it almost always does get memory from the stack.

    As you are inspecting that function in IDA, jump to a function referencing your function and show how it's called there.
    Hey, it compiles! Ship it!

  10. #10
    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)
    He's using RivalFr's EndScene via ASM hook, so i bet injecting compiled C++ isn't an option for him.
    Otherwise he could simply use the function definition provided by IDA.

  11. #11
    SKU's Avatar Contributor
    Reputation
    306
    Join Date
    May 2007
    Posts
    565
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might also want to provide the actual assembly of the function and a (few) snippet(s) where the function's being called..
    The hexrays-generated signature can't always be trusted blindly.

  12. #12
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This thread is the new spam central.
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  13. #13
    SKU's Avatar Contributor
    Reputation
    306
    Join Date
    May 2007
    Posts
    565
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, tinyurl or something.. :/

  14. #14
    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)
    Ok and my post was deleted because of spam...

    Edit by Parog: Maybe if you didn't quote the spam and re-spammed the link we woudn't do that. Keep on doing it and I'll ban you for spamming too.
    Last edited by Parog; 06-23-2011 at 02:13 AM.

  15. #15
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is getting ridiculous.

Page 1 of 2 12 LastLast

Similar Threads

  1. lets list what method to bot
    By bopoiu in forum GW2 Bots and Programs
    Replies: 5
    Last Post: 09-02-2012, 02:12 PM
  2. [ArcEmu] Logging in to game server, returns to list of realms.
    By dannyzokun in forum WoW EMU Questions & Requests
    Replies: 27
    Last Post: 03-18-2010, 07:26 AM
All times are GMT -5. The time now is 10:11 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search