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 


[C#]asm scripts in VC# ?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Thu Dec 18, 2008 6:39 am    Post subject: [C#]asm scripts in VC# ? Reply with quote

is there any way to put asm code in C#? in C++ i used __asm but there it doesnt work :O?

eg. i want to put that code
Quote:

[ENABLE]
00001337:
db 0F 84

[DISABLE]
00001337:
db 0F 85


on button1_Click


i know method
Quote:
byte[] ByteArray = { 0x90, 0x90 }; //this mean nop ye?

but how to put script there? Shocked


Last edited by Wiw3K on Thu Dec 18, 2008 8:29 am; edited 1 time in total
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Thu Dec 18, 2008 6:47 am    Post subject: Reply with quote

i don't code in c# so not sure about the first question but the second one, yes that declares an array of size 2 with byte elements each of value 0x90 which is 2 NOPs. at least if the array declarations are the same as in c++.
Back to top
View user's profile Send private message
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Thu Dec 18, 2008 7:17 am    Post subject: Reply with quote

C# Does not have an __asm function.
Back to top
View user's profile Send private message MSN Messenger
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Thu Dec 18, 2008 7:57 am    Post subject: Reply with quote

Zerith wrote:
C# Does not have an __asm function.

so how do i convert asm script i put in post 1 to VC# ? Confused
Back to top
View user's profile Send private message
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Thu Dec 18, 2008 8:18 am    Post subject: Reply with quote

Wiw3K wrote:
Zerith wrote:
C# Does not have an __asm function.

so how do i convert asm script i put in post 1 to VC# ? Confused


WriteProcessMemory().
Back to top
View user's profile Send private message MSN Messenger
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Thu Dec 18, 2008 8:36 am    Post subject: Reply with quote

@up
huh?

Found on cef this
Quote:
Easily import a DLL made in C++ into your C# project and use the function from there, it'll work just as nicely.

h o w ? Shocked
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Dec 18, 2008 8:42 am    Post subject: Reply with quote

Rolling Eyes don't expect to do this without learning anything
You'll have to learn C++. And I'm not talking about just learning a bit of it cause you won't get anywhere.
If you want to use C# then like he said use WriteProcessMemory. did you even attempt to search it?

_________________
Back to top
View user's profile Send private message
arigity
Advanced Cheater
Reputation: 0

Joined: 03 Jul 2008
Posts: 65
Location: middle of nowhere.

PostPosted: Thu Dec 18, 2008 9:03 am    Post subject: Reply with quote

i'm not much of a C# guy but try something like this.

byte[] hack_on = { 0x0F, 0x84 };
byte[] hack_off = { 0x0F, 0x85 };


if(!mypatch)
{
writeProcessmemory(handle, address, hack_on, 2,0);
mypatch = 1;
}
else
{
writeProcessmemory(handle,address,hack_off,2,0);
mypatch =0;
}


as for inline asm, while C# doesn't normally have support for it their
are somewhat decent alternatives such as shynds blackmagic library

_________________
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Thu Dec 18, 2008 9:03 am    Post subject: Reply with quote

why don't you write a dll in C++, the use inline asm to make you're script and then import that function into your C# project?
Back to top
View user's profile Send private message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Thu Dec 18, 2008 10:11 am    Post subject: Reply with quote

lurc wrote:
Rolling Eyes don't expect to do this without learning anything
You'll have to learn C++. And I'm not talking about just learning a bit of it cause you won't get anywhere.
If you want to use C# then like he said use WriteProcessMemory. did you even attempt to search it?

yes i searched on google and i found change adress , etc. about WriteProcessMemory, i want put Script in C# not simple adress -.-.


1qaz wrote:
why don't you write a dll in C++, the use inline asm to make you're script and then import that function into your C# project?

yea i want to do that but i dont know how to propertly write it in C++ then use in C#
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Dec 18, 2008 10:16 am    Post subject: Reply with quote

Just write the bytes directly with WriteProcessMemory, same result.
Back to top
View user's profile Send private message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Thu Dec 18, 2008 10:28 am    Post subject: Reply with quote

slovach wrote:
Just write the bytes directly with WriteProcessMemory, same result.

ok so

Code:
        private void button1_Click(object sender, EventArgs e)
        {
            IntPtr bytesout;
            byte[] NewVal = { 0x90 };

            return WriteProcessMemory(ProcessHandle, (IntPtr)0x0001337 , NewVal, (UIntPtr)NewVal.Length, out bytesout);
            }

give error
Quote:
Since 'simpleTrainer.Form1.button1_Click(object, System.EventArgs)' returns void, a return keyword must not be followed by an object expression



---edit---
when i delete return , error dissapear , can it be without return?
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Dec 18, 2008 10:31 am    Post subject: Reply with quote

read the error, it tells you exactly what's wrong.
get rid of the return.
Back to top
View user's profile Send private message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Thu Dec 18, 2008 10:36 am    Post subject: Reply with quote

slovach wrote:
read the error, it tells you exactly what's wrong.
get rid of the return.


ok no errors, my button looks that:
Code:
        private void button1_Click(object sender, EventArgs e)
        {
            WindowHandle = FindWindow("MapleStoryClass", "MapleStory");
            GetWindowThreadProcessId(WindowHandle, out ProcID);
            IntPtr bytesout;
            ProcessHandle = OpenProcess(0x1F0FFF, 1, ProcID);
            byte[] NewVal = { 0x90 };

            WriteProcessMemory(ProcessHandle, (IntPtr)0x0001337 , NewVal, (UIntPtr)NewVal.Length, out bytesout);
            }


this example should nop adress 00001337 ? Wink
Back to top
View user's profile Send private message
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Thu Dec 18, 2008 10:44 am    Post subject: Reply with quote

Wiw3K wrote:
slovach wrote:
read the error, it tells you exactly what's wrong.
get rid of the return.


ok no errors, my button looks that:
Code:
        private void button1_Click(object sender, EventArgs e)
        {
            WindowHandle = FindWindow("MapleStoryClass", "MapleStory");
            GetWindowThreadProcessId(WindowHandle, out ProcID);
            IntPtr bytesout;
            ProcessHandle = OpenProcess(0x1F0FFF, 1, ProcID);
            byte[] NewVal = { 0x90 };

            WriteProcessMemory(ProcessHandle, (IntPtr)0x0001337 , NewVal, (UIntPtr)NewVal.Length, out bytesout);
            }


this example should nop adress 00001337 ? Wink

You used FindWindow with both the Class and the Window ...Neutral,
use just the class.

Remember though, you need to nop ALL the bytes in that address.
And yes, it will work in case 0x000001337 exists.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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