Raised This Month: $12 Target: $400
 3% 

[L4D2] Ladder Rambos -- Shoot from ladders!


Post New Thread Reply   
 
Thread Tools Display Modes
epzminion
AlliedModders Donor
Join Date: Jan 2011
Old 06-16-2019 , 03:13   Re: [L4D2] Ladder Rambos -- Shoot from ladders!
Reply With Quote #11

Quote:
Originally Posted by spumer View Post
You can try recompile with https://github.com/spumer/Left4Fix/b...rhelpers.h#L61
My ProtectMemory version take into account multiple memory pages.
This would also crash in this case because it isn't taking into account the offset when it calls ProtectMemory in ApplyPatch.

You would need this change also to make the page(s) at the patch location writable:
Code:
inline void ApplyPatch(void *address, int offset, const patch_t *patch, patch_t *restore)
{
	unsigned char *addr = (unsigned char *)address + offset;
	ProtectMemory((void *)addr, 20, PAGE_EXECUTE_READWRITE);

Last edited by epzminion; 06-16-2019 at 03:18.
epzminion is offline
spumer
Senior Member
Join Date: Aug 2011
Old 06-16-2019 , 04:08   Re: [L4D2] Ladder Rambos -- Shoot from ladders!
Reply With Quote #12

Quote:
Originally Posted by epzminion View Post
This would also crash in this case because it isn't taking into account the offset when it calls ProtectMemory in ApplyPatch.

You would need this change also to make the page(s) at the patch location writable:
Code:
inline void ApplyPatch(void *address, int offset, const patch_t *patch, patch_t *restore)
{
	unsigned char *addr = (unsigned char *)address + offset;
	ProtectMemory((void *)addr, 20, PAGE_EXECUTE_READWRITE);
It's not important in this case, cause patch size is 1 byte. 1 is lower than 20.

https://github.com/Attano/LadderRamb..._patch.cpp#L75
__________________
spumer is offline
epzminion
AlliedModders Donor
Join Date: Jan 2011
Old 06-16-2019 , 05:02   Re: [L4D2] Ladder Rambos -- Shoot from ladders!
Reply With Quote #13

Quote:
Originally Posted by spumer View Post
It's not important in this case, cause patch size is 1 byte. 1 is lower than 20.

https://github.com/Attano/LadderRamb..._patch.cpp#L75
The patch size isn't what is relevant to the crash that's happening here. If you re-read my post, you'll see I never indicated it was.

You fixed part of the problem with your version, but the remaining issue is that mprotect still isn't guaranteed to be called on the correct memory page. You are calling it on the memory page(s) that contain 'address' and 'address + 20 bytes'. Then you are proceeding to write to memory at 'address + offset'. The offset is 181 bytes.

As I said in my earlier post, you should be calling ProtectMemory with 'address + offset' (not 'address' alone) since that is the memory that is going to need write access. What you have will work up until the offset causes the patch location to cross the page boundary, which is what is happening here.
epzminion is offline
spumer
Senior Member
Join Date: Aug 2011
Old 06-16-2019 , 06:22   Re: [L4D2] Ladder Rambos -- Shoot from ladders!
Reply With Quote #14

Yeah, you are right. I really missed that.
__________________
spumer is offline
spumer
Senior Member
Join Date: Aug 2011
Old 06-16-2019 , 22:51   Re: [L4D2] Ladder Rambos -- Shoot from ladders!
Reply With Quote #15

So, i will try to fix it but don't tested it.

Applied Left4Fix detourhelpers.h version + ApplyPatch fixups what epzminion talking about.
All changes in .patch file in attachment.

Update: Tested. No crashes!
Attached Files
File Type: so ladder_rambos.ext.so (166.0 KB, 232 views)
File Type: patch fix_seg_fault.patch (2.6 KB, 227 views)
__________________

Last edited by spumer; 06-18-2019 at 03:33.
spumer is offline
TrueSurvivor
Member
Join Date: Jun 2010
Old 07-25-2019 , 20:55   Re: [L4D2] Ladder Rambos -- Shoot from ladders!
Reply With Quote #16

Quote:
Originally Posted by spumer View Post
So, i will try to fix it but don't tested it.

Applied Left4Fix detourhelpers.h version + ApplyPatch fixups what epzminion talking about.
All changes in .patch file in attachment.

Update: Tested. No crashes!
Can confirm it's working here, swell job. (:
TrueSurvivor is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 02-17-2021 , 15:34   Re: [L4D2] Ladder Rambos -- Shoot from ladders!
Reply With Quote #17

Improved version of this concept: https://forums.alliedmods.net/showthread.php?t=330703
__________________
Spirit_12 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode