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++ inline asm
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Wed Sep 17, 2008 2:30 pm    Post subject: Reply with quote

kitterz wrote:
1qaz wrote:
i think something wrong with my virtualprotect cuz it fail all the time changing the memory protection to execute_readwrite


Im pretty sure you need to hook hop it.

Code:
//VProtect Bypass
static const FARPROC Vprotect = (FARPROC)((DWORD)GetProcAddress(GetModuleHandleA("kernel32.dll"), "VirtualProtectEx")+5);
_declspec(naked) BOOL WINAPI FixMem(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect)
{
   _asm
   {
      mov edi,edi
      push ebp
      mov ebp,esp
      jmp Vprotect
   }
}

wow delete your post while you can!
Oh nvm you can't anymore.
The reason why we use the trampoline its to bypass GG...
He doesnt have to worry about GameGuard.
Besides I'm almost sure that MineSweeper is already as W/R/E.

_________________
Gone
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Wed Sep 17, 2008 3:33 pm    Post subject: Reply with quote

GMZorita wrote:
kitterz wrote:
1qaz wrote:
i think something wrong with my virtualprotect cuz it fail all the time changing the memory protection to execute_readwrite


Im pretty sure you need to hook hop it.

Code:
//VProtect Bypass
static const FARPROC Vprotect = (FARPROC)((DWORD)GetProcAddress(GetModuleHandleA("kernel32.dll"), "VirtualProtectEx")+5);
_declspec(naked) BOOL WINAPI FixMem(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect)
{
   _asm
   {
      mov edi,edi
      push ebp
      mov ebp,esp
      jmp Vprotect
   }
}

wow delete your post while you can!
Oh nvm you can't anymore.
The reason why we use the trampoline its to bypass GG...
He doesnt have to worry about GameGuard.
Besides I'm almost sure that MineSweeper is already as W/R/E.


Oh.... Very Happy
LOL I did not reall all the post...I got it wrong this time Laughing

_________________
Back to top
View user's profile Send private message Send e-mail
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Wed Sep 17, 2008 4:15 pm    Post subject: Reply with quote

You only need to virtual protect if you're accessing memory from another program. Since you're using a dll and will be inside the address space of the program you're trying to edit, you don't need to use it.
You shouldn't use naked because you're just using the function as a regular function, not as something injected.
try *(BYTE[6]*)(address) = {0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; instead of the ASM to see whether it's what you're doing that's messing it up or if it's how you're doing it.

_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Wed Sep 17, 2008 4:42 pm    Post subject: Reply with quote

Jani wrote:
oib111 wrote:
Just wondering. What exactly is the prologue and epilogue when you talk about naked functions?
There's none. That's why it's called naked.


I thought naked meant you have to create your own? And even so, I would still like to know what it is =P

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
nog_lorp
Grandmaster Cheater
Reputation: 0

Joined: 26 Feb 2006
Posts: 743

PostPosted: Wed Sep 17, 2008 4:58 pm    Post subject: Reply with quote

Naked stops the prologue/epilogue from being generated. You still need to make one to stop it from crashing, unless you want it to lead in to another function.
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Wed Sep 17, 2008 5:27 pm    Post subject: Reply with quote

Ok, well I still don't get what the prologue and epilogue is?
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Wed Sep 17, 2008 5:40 pm    Post subject: Reply with quote

oib111 wrote:
Ok, well I still don't get what the prologue and epilogue is?


http://en.wikipedia.org/wiki/Function_prologue
Back to top
View user's profile Send private message MSN Messenger
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Wed Sep 17, 2008 6:35 pm    Post subject: Reply with quote

HalfPrime wrote:
You only need to virtual protect if you're accessing memory from another program. Since you're using a dll and will be inside the address space of the program you're trying to edit, you don't need to use it.
You shouldn't use naked because you're just using the function as a regular function, not as something injected.
try *(BYTE[6]*)(address) = {0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; instead of the ASM to see whether it's what you're doing that's messing it up or if it's how you're doing it.
... No. You must use VirtualProtect, depending on the access of the code, even with a dll.
_________________
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Wed Sep 17, 2008 6:48 pm    Post subject: Reply with quote

Really? I've never had any trouble with that. Odd.
_________________
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Wed Sep 17, 2008 8:09 pm    Post subject: Reply with quote

Sponge is correct. If you do a "mov" and the page's access doesn't allow write, then the program crashes.
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Wed Sep 17, 2008 8:16 pm    Post subject: Reply with quote

yah always do VirtualProtects @ ,PAGE_EXECUTE_READWRITE
_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
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 Sep 18, 2008 5:12 am    Post subject: Reply with quote

tell me what causes the failure with my virtualprotect
Code:

VirtualProtect((LPVOID)Address,6,PAGE_EXECUTE_READWRITE,0)

Address - means the flags address - 0x0100346E
6 - means the bytes so i saw it's 6 bytes
etc ...
it keeps failing me and i dont know why

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

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Thu Sep 18, 2008 5:20 am    Post subject: Reply with quote

Quote:
lpflOldProtect [out]
A pointer to a variable that receives the previous access protection value of the first page in the specified region of pages. If this parameter is NULL or does not point to a valid variable, the function fails.


~Cheers
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 Sep 18, 2008 5:53 am    Post subject: Reply with quote

so i assume that the previous access protection of the memory was PAGE_READONLY ??
edit: oops didn't see the [out] now i got it (tried to put PAGE_READONLY and couldn't understand why it didnt work)

_________________
Stylo


Last edited by Stylo on Thu Sep 18, 2008 5:57 am; edited 1 time in total
Back to top
View user's profile Send private message
jackyyll
Expert Cheater
Reputation: 0

Joined: 28 Jan 2008
Posts: 143
Location: here

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

Yeah, VirtualProtect requires that you have the dwOldProtect or else it fails.
Back to top
View user's profile Send private message AIM Address 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 Previous  1, 2, 3
Page 3 of 3

 
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