[C#][asm] Examples menu

User Tag List

Results 1 to 4 of 4
  1. #1
    Scorpiona's Avatar Active Member
    Reputation
    17
    Join Date
    Mar 2009
    Posts
    42
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [C#][asm] Examples

    These are just some things I've worked out while coding and figured I'd share. I don't know asm and have been learning as I go along (thanks to Nesox for your help); please feel free to critique if there's something I should know, or that I've missed.

    ClickToMove (remember, unused fields can be left 0)
    Code:
                    uint pMe = 0, pInteractGuid = 0, pClickPos = 0;
                    try {
                        pMe = Allocate(4);
                        Memory.WriteUInt(pMe, Me);
                        pInteractGuid = Allocate(8);
                        Memory.WriteUInt64(pInteractGuid, interactGuid);
                        pClickPos = Allocate(pointSize);
                        Memory.WriteObject(pClickPos, clickPos);
    
                        ClearAndExecute(
                            "push "+precision,
                            "push "+pClickPos,
                            "push "+pInteractGuid,
                            "push "+(uint)clickType,
                            "mov ecx, ["+pMe+"]",
                            "call "+p_ClickToMove,
                            "retn"
                            );
                    } catch(MemoryReadFailedException) {
                    } finally {
                        if(pMe!=0)
                            Memory.FreeMemory(pMe);
                        if(pInteractGuid!=0)
                            Memory.FreeMemory(pInteractGuid);
                        if(pClickPos!=0)
                            Memory.FreeMemory(pClickPos);
                    }
    GetLocalizedText
    Code:
                    uint lpLua = 0, pReturnBlock = 0;
                    string szReturn = null;
                    try {
                        lpLua = Allocate(szLuaVariable.Length);
                        Memory.WriteASCIIString(lpLua, szLuaVariable);
                        pReturnBlock = Allocate(255);
    
                        if(pReturnBlock==0) return null;
    
                        ClearAndExecute(
                            "push -1",
                            "push " + lpLua,
                            "mov ecx, " + pMe,
                            "call " + lua_getlocalizedtext,
                            "mov ["+pReturnBlock+"], eax",
                            "retn"
                        );
    
                        var pReturn = Memory.ReadUInt(pReturnBlock);
                        if(pReturn!=0) szReturn = Memory.ReadASCIIString(pReturn, 255);
                    } catch(MemoryReadFailedException) {
                    } finally {
                        if(lpLua != 0)
                            Memory.FreeMemory(lpLua);
                        if(pReturnBlock != 0)
                            Memory.FreeMemory(pReturnBlock);
                    }
    DoString (mostly copypasta from Nesox's aHook wrapper example)
    Code:
                    uint lpLua = 0;
    
                    try {
                        lpLua = Allocate(szLua.Length + szLuaFile.Length + 4);
    
                        var lpLuaFile = lpLua + (uint)szLua.Length + 2;
    
                        Memory.WriteASCIIString(lpLua, szLua);
                        Memory.WriteASCIIString(lpLuaFile, szLuaFile);
    
                        ClearAndExecute(
                            "push " + pState,
                            "push " + lpLuaFile,
                            "push " + lpLua,
                            "call " + lua_dostring,
                            "add esp, 0xC",
                            "retn"
                            );
                    } catch(MemoryReadFailedException) {
                    } finally {
                        if(lpLua != 0)
                            Memory.FreeMemory(lpLua);
                    }
    UpdateHardwareEvent
    Code:
                    ClearAndExecute(
                        "call "+p_GetTimestamp,
                        "mov ["+p_LastHardwareAction+"], eax",
                        "retn"
                        );

    [C#][asm] Examples
  2. #2
    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)
    Originally Posted by Scorpiona View Post
    DoString (mostly copypasta from Nesox's aHook wrapper example)
    Code:
                    uint lpLua = 0;
    
                    try {
                        lpLua = Allocate(szLua.Length + szLuaFile.Length + 4);
    
                        var lpLuaFile = lpLua + (uint)szLua.Length + 2;
    
                        Memory.WriteASCIIString(lpLua, szLua);
                        Memory.WriteASCIIString(lpLuaFile, szLuaFile);
    
                        ClearAndExecute(
                            "push " + pState,
                            "push " + lpLuaFile,
                            "push " + lpLua,
                            "call " + lua_dostring,
                            "add esp, 0xC",
                            "retn"
                            );
                    } catch(MemoryReadFailedException) {
                    } finally {
                        if(lpLua != 0)
                            Memory.FreeMemory(lpLua);
                    }
    You're not freeing the allocated Lua file string memory.
    [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

  3. #3
    Scorpiona's Avatar Active Member
    Reputation
    17
    Join Date
    Mar 2009
    Posts
    42
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by MaiN View Post
    You're not freeing the allocated Lua file string memory.
    lpLuaFile is never allocated to, it's only used to write szLuaFile in the correct position. lpLua is the pointer to the allocated block, and the lua file is being written within that block. It is freed along with lpLua.

  4. #4
    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)
    Originally Posted by Scorpiona View Post
    lpLuaFile is never allocated to, it's only used to write szLuaFile in the correct position. lpLua is the pointer to the allocated block, and the lua file is being written within that block. It is freed along with lpLua.
    Sorry, I completely missed that!
    [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

Similar Threads

  1. Replies: 25
    Last Post: 11-25-2007, 11:14 AM
  2. [Example] How to not be a millionare.
    By Kartio in forum Community Chat
    Replies: 16
    Last Post: 11-06-2007, 10:26 AM
  3. REQUESTS (for example BEm->BEf)
    By logo in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 07-06-2007, 07:41 AM
  4. Glider Example
    By fonstump in forum World of Warcraft General
    Replies: 1
    Last Post: 02-14-2007, 07:22 AM
  5. Replies: 21
    Last Post: 09-11-2006, 04:43 PM
All times are GMT -5. The time now is 06:32 PM. 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