Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[VB.NET] Manually executing asm code?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Mal1t1a
Cheater
Reputation: 0

Joined: 03 Jan 2010
Posts: 40

PostPosted: Mon Apr 25, 2011 3:31 am    Post subject: [VB.NET] Manually executing asm code? Reply with quote

Hi there, I'm wondering if there is a way to execute asm code in VB.NET? I write to the memory, and then after I've written (because it has to be manually executed by the client), I want to be able to have it run right after I'm finished writing. Is this possible? If so, how do I do it?

The way it works: Client Executes Action -> Action Calls ASM -> Game Updates.

I want it to be like: Write Memory -> Force ASM Call -> Game Updates.

This is how it would be:
mov [YYYYYYYY], eax <- eax would be my inserted value.
mov cl, [YYYYYYYY] <- The call I want to execute.

Is it possible to do in VB.Net?

Thanks.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Apr 25, 2011 2:23 pm    Post subject: Reply with quote

Look into:
WriteProcessMemory
CreateRemoteThread

You can write a cave that can be called with CreateRemoteThread. Or write a cave in a location where you need the code to execute and have the game jump to it when needed.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Mal1t1a
Cheater
Reputation: 0

Joined: 03 Jan 2010
Posts: 40

PostPosted: Mon Apr 25, 2011 5:05 pm    Post subject: Reply with quote

Wiccaan wrote:
Look into:
WriteProcessMemory
CreateRemoteThread

You can write a cave that can be called with CreateRemoteThread. Or write a cave in a location where you need the code to execute and have the game jump to it when needed.


Yes I am using WriteProcessMemory to write my instructions, I don't even need to allocate memory either as I have found a perfect spot in the games memory, all I need to do now is figure out how to call it with CreateRemoteThread EXample, so I'm googling all over the place to find an example that seems simple enough to follow.
Back to top
View user's profile Send private message
Innovation
Grandmaster Cheater
Reputation: 12

Joined: 14 Aug 2008
Posts: 617

PostPosted: Mon Apr 25, 2011 7:35 pm    Post subject: Reply with quote

Code:
BOOL bExecuteAssembly(HANDLE hProcess, LPCVOID lpAssembly, SIZE_T dwSize)
{
   BOOL bSuccess = FALSE;
   LPVOID lpBaseAddress = VirtualAllocEx(hProcess, NULL, dwSize, MEM_COMMIT, PAGE_EXECUTE);
   if(lpBaseAddress != NULL)
   {
      if(WriteProcessMemory(hProcess, lpBaseAddress, lpAssembly, dwSize, NULL))
      {
         HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)lpBaseAddress, NULL, 0, NULL);
         if(hThread != NULL)
         {       
            WaitForSingleObject(hThread, INFINITE);
            CloseHandle(hThread);
            bSuccess = TRUE;
         }
      }
      VirtualFreeEx(hProcess, lpBaseAddress, 0, MEM_RELEASE);
   }
   return bSuccess;
}

I don't know Visual Basic .NET, but I'm sure that you could do something similar using P/Invoke.


Last edited by Innovation on Thu May 19, 2011 5:09 am; edited 1 time in total
Back to top
View user's profile Send private message
Mal1t1a
Cheater
Reputation: 0

Joined: 03 Jan 2010
Posts: 40

PostPosted: Tue Apr 26, 2011 11:31 pm    Post subject: Reply with quote

Well, I already have inserted the Assembly code into the Process, err rather, overwritten the previous Code. However, I need to execute it after I overwrite it, as for it to be executed it requires user input, and I'm trying to bypass that.
I have not been able to get CreateRemoteThread working though, and I've spent several hours trying, and searching. In the end, I ended up deleting the code I had as nothing worked.. If needed to see what, I could try again.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites