[Question] Why injection doesnt work menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    sercankd's Avatar Member
    Reputation
    14
    Join Date
    Nov 2006
    Posts
    46
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Question] Why injection doesnt work

    I am new to memory editing stuff, trying to make something my own with blackmagic library. i have readed some tutorials on this forums.
    this is my code, its just simple. and i run visual studio in admin mode
    Code:
    BlackMagic wow = new BlackMagic(); //Create new function to open wow process            wow.OpenProcessAndThread(SProcess.GetProcessFromProcessName("wow"));
                IntPtr baseWOW = wow.MainModule.BaseAddress;
                wow.WriteInt((uint)baseWOW + 0x00965AC8, 0);
                textBox1.Text = wow.ReadFloat((uint)baseWOW + 0x00965AC8).ToString();

    [Question] Why injection doesnt work
  2. #2
    xalcon's Avatar Contributor ふたなり
    Authenticator enabled
    Reputation
    198
    Join Date
    Oct 2008
    Posts
    291
    Thanks G/R
    20/58
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you are writing an int and reading a float - for 0 this might work, but I've no idea what you are trying to accomplish here. It would also help if you tell us what exactly is not working... does it crash? Wrong values?
    "Threads should always commit suicide - they should never be murdered" - DirectX SDK

  3. Thanks 435 (1 members gave Thanks to xalcon for this useful post)
  4. #3
    sercankd's Avatar Member
    Reputation
    14
    Join Date
    Nov 2006
    Posts
    46
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope it doesnt change the value at all, its a wall climbing offset(private server). when i use it in cheat engine and change it to zero it works fine. but in this code it doesnt work, i know its float i tried everything to get it work

  5. #4
    Sarick's Avatar Contributor
    Reputation
    269
    Join Date
    Apr 2007
    Posts
    397
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are trying to write Int to a float.
    Try do do wow.WriteFloat(wow.ReadUInt((uint)baseWOW) + 0x00965AC8 , 0);

  6. Thanks 435 (1 members gave Thanks to Sarick for this useful post)
  7. #5
    sercankd's Avatar Member
    Reputation
    14
    Join Date
    Nov 2006
    Posts
    46
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Sarick View Post
    You are trying to write Int to a float.
    Try do do wow.WriteFloat(wow.ReadUInt((uint)baseWOW) + 0x00965AC8 , 0);
    its not the problem, since i am writing zero as value. i am aware of that its a float type.

  8. #6
    Sarick's Avatar Contributor
    Reputation
    269
    Join Date
    Apr 2007
    Posts
    397
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by sercankd View Post
    its not the problem, since i am writing zero as value. i am aware of that its a float type.
    Well try that above. Example how I write to float in my small tool for 1.12.1, black magic aswell.
    wow.WriteFloat(wow.ReadUInt(wow.ReadUInt(wow.ReadUInt(playerx) + 0x20) + 0x118 ) + 0x10, 5241);

    Could also be that you have the wrong address.
    Last edited by Sarick; 06-20-2014 at 10:33 AM.

  9. #7
    sercankd's Avatar Member
    Reputation
    14
    Join Date
    Nov 2006
    Posts
    46
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Sarick View Post
    Well try that above. Example how I write to float in my small tool for 1.12.1, black magic aswell.
    wow.WriteFloat(wow.ReadUInt(wow.ReadUInt(wow.ReadUInt(playerx) + 0x20) + 0x118 ) + 0x10, 5241);

    Could also be that you have wrong the address.
    textBox1.Text = wow.ReadFloat((uint)baseWOW + 0x00965AC.ToString();
    this part of the code gives exact value, so it cant be wrong adress.

  10. #8
    namreeb's Avatar Legendary

    Reputation
    658
    Join Date
    Sep 2008
    Posts
    1,023
    Thanks G/R
    7/215
    Trade Feedback
    0 (0%)
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    This probably isn't it, but in your original post the OpenProcessAndThread line is on the same line as and follows a single-line comment. That would have the OpenProcessAndThread statement go un-executed. Also, are you sure you don't need to do anything to adjust the page permissions?

  11. #9
    xalcon's Avatar Contributor ふたなり
    Authenticator enabled
    Reputation
    198
    Join Date
    Oct 2008
    Posts
    291
    Thanks G/R
    20/58
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by namreeb View Post
    This probably isn't it, but in your original post the OpenProcessAndThread line is on the same line as and follows a single-line comment. That would have the OpenProcessAndThread statement go un-executed. Also, are you sure you don't need to do anything to adjust the page permissions?
    The OpenProcessAndThread() would be my guess too, but he doesnt need to ajust page permissions, BlackMagic is handling everything internally. I would expect blackmagic would crash when you try to read/write something without actually being attached to a process, but I havn't looked into the code myself.
    "Threads should always commit suicide - they should never be murdered" - DirectX SDK

  12. #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)
    The missing OpenProcessAndThread call sounds plausible, but wouldn't it throw then on the Read/Write call?

    My other guess would be that he has ASLR disabled and 0x00965AC8 is an absolute address not a relative one.

    OP, what version of WoW are you working on?

  13. #11
    sercankd's Avatar Member
    Reputation
    14
    Join Date
    Nov 2006
    Posts
    46
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i am working with 5.4.0 17399
    i put a breakpoint to where it begins writing it gave me some error
    + Thrown: "WriteBytes failed! Number of bytes actually written differed from request."

  14. #12
    xalcon's Avatar Contributor ふたなり
    Authenticator enabled
    Reputation
    198
    Join Date
    Oct 2008
    Posts
    291
    Thanks G/R
    20/58
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Then its either a problem with your OpenProcessAndThreat or a permission problem (are you really running VS as an administrator?). WriteInt calls internally WriteBytes which is defined like
    Code:
    public static bool WriteBytes(IntPtr hProcess, uint dwAddress, byte[] lpBytes, int nSize)
    {
    	IntPtr lpBuffer = IntPtr.Zero;
    	int iBytesWritten = 0;
    
    	try
    	{
    		lpBuffer = Marshal.AllocHGlobal(Marshal.SizeOf(lpBytes[0]) * nSize); //allocate unmanaged memory
    
    		Marshal.Copy(lpBytes, 0, lpBuffer, nSize);
    
    		iBytesWritten = WriteRawMemory(hProcess, dwAddress, lpBuffer, nSize);
    
    		if (nSize != iBytesWritten)
    			throw new Exception("WriteBytes failed!  Number of bytes actually written differed from request.");
    	}
    	catch
    	{
    		return false;
    	}
    	finally
    	{
    		if (lpBuffer != IntPtr.Zero)
    			Marshal.FreeHGlobal(lpBuffer);
    	}
    
    	return true;
    }
    
    static int WriteRawMemory(IntPtr hProcess, uint dwAddress, IntPtr lpBuffer, int nSize)
    {
    	IntPtr iBytesWritten = IntPtr.Zero;
    		if (!Imports.WriteProcessMemory(hProcess, dwAddress, lpBuffer, nSize, out iBytesWritten))
    		return 0;
    
    	return (int)iBytesWritten;
    }
    As you can see, there is no check if hProcess is actually > 0.

    BlackMagic.OpenProcessAndThread returns true/false - check for that value. If it returns true, try to debug the WriteInt method you are using.
    You can also try to call "GetLastError" via P/Invoke to get the errorcode after your WriteInt.
    Last edited by xalcon; 06-21-2014 at 01:51 AM.
    "Threads should always commit suicide - they should never be murdered" - DirectX SDK

  15. #13
    sercankd's Avatar Member
    Reputation
    14
    Join Date
    Nov 2006
    Posts
    46
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But this part of code works, doesnt it mean OpenProcessAndThread is fine?
    textBox1.Text = wow.ReadFloat((uint)baseWOW + 0x00965AC.ToString();


  16. #14
    Corthezz's Avatar Elite User Authenticator enabled
    Reputation
    386
    Join Date
    Nov 2011
    Posts
    325
    Thanks G/R
    183/98
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Had the same problem when I was about to program my wallclimb hack on 1.12.1.
    First of all you are good to go checking the last win32 error (Marshal.GetLastWin32Error-Methode (System.Runtime.InteropServices)) after calling the writeInt function.

    In my case the page of the address was set to the readonly flag making any attempt to change its value impossible. You can adjust the page permission with VirtualProtectEx:
    pinvoke.net: virtualprotectex (kernel32)
    Check my blog: https://zzuks.blogspot.com

  17. #15
    xalcon's Avatar Contributor ふたなり
    Authenticator enabled
    Reputation
    198
    Join Date
    Oct 2008
    Posts
    291
    Thanks G/R
    20/58
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ah yeah, now this makes sense. Back when I used to use blackmagic I was never writing to the .text segment (like he is doing, I guess), so thats why I never had to change page protection.
    Looks like blackmagic is not changing protection itself.
    "Threads should always commit suicide - they should never be murdered" - DirectX SDK

Page 1 of 2 12 LastLast

Similar Threads

  1. [Question] Need help [MWCS doesnt work]
    By Hiselor in forum WoW ME Questions and Requests
    Replies: 3
    Last Post: 08-27-2010, 10:47 AM
  2. [Question] Why doesnt blink work right now?
    By flop159 in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 06-01-2008, 09:09 PM
  3. [Question]Disconnect Players[Tested] Doesnt Work
    By Juicyz in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 03-29-2008, 06:33 PM
  4. [Question] My .lua doesnt work
    By Creepfold in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 12-20-2007, 07:32 PM
  5. [Question] Why wont it work?
    By kekburtbhkeke in forum WoW ME Questions and Requests
    Replies: 3
    Last Post: 05-01-2007, 09:16 AM
All times are GMT -5. The time now is 11:54 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