Raised This Month: $ Target: $400
 0% 

Patching memory


Post New Thread Reply   
 
Thread Tools Display Modes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-09-2013 , 17:27   Re: Patching memory
Reply With Quote #21

To block, don't call original function.
__________________
Arkshine is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 02-09-2013 , 17:38   Re: Patching memory
Reply With Quote #22

I want to try blocking RoundEnd with my module. I have hooked sub_100CFCD0,

PHP Code:
short pattern[] = {0x8B0x4C, -1, -10x8D0x44, -1, -10x500x510x68, -1, -1, -1, -10xE8, -1, -1, -1, -10x68, -1, -1, -1, -10x68, -1, -1, -1, -10x6A0x050xFF, -1, -1, -, -1, -10x830xC4, -1};

int sub_100CFCD0(const char *Format, ...)
{
  
va_list va// [sp+8h] [bp+8h]@1

  
va_start(vaFormat);
  
vsprintf(byte_10175C48Formatva);
  return ((
int (*)(signed int, const char *, ...))dword_10162434)(5"%s");
}

void HOOK(const char *Format)
{
    
print_srvconsole"%s\n",Format);

its working


but I dont understand how to block it
Attached Thumbnails
Click image for larger version

Name:	Безымянный.png
Views:	84
Size:	32.7 KB
ID:	115755  
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-09-2013 , 17:45   Re: Patching memory
Reply With Quote #23

This is not this function if you want to block round end.
__________________
Arkshine is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 02-09-2013 , 17:54   Re: Patching memory
Reply With Quote #24

return sub_100CFCD0("World triggered \"Round_End\"\n");

called is int sub_100CFCD0(const char *Format, ...)

can you tell me what function I need to hook. And explain detailed how to block it
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-09-2013 , 18:18   Re: Patching memory
Reply With Quote #25

CHalfLifeMultiplay::CheckWinConditions() and to block, just don't return original function. But blocking the whole function is not a good idea, the first part of the function is a loop to update players count. You can check my InfiniteRound plugin (the v2 version).
__________________

Last edited by Arkshine; 02-09-2013 at 18:20.
Arkshine is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 02-09-2013 , 18:38   Re: Patching memory
Reply With Quote #26

I hook function

void HooK_CheckWinCondition( int this )
{
But I do not understand how to not return the original function
}

I'll watch your plugin

PHP Code:
bool createPatch()
{
    
short pattern[] = {0x83,0xEC,0x38,0x53,0x55,0x8B,0xE9,0x56,0x33,0xF6,0x57,0x8A,0x85,0xB4,0x02,0x00,0x00,0x89,0x74,0x24,0x10,0x84,0xC0,0x74,-1,0x39,0x75,0x74,0x0F,0x85,-1,-1,-1,-1};

// signature from "Round Terminator"
    
    
int pLength sizeof(pattern)/sizeof(short);

    
bool findet false;

    
HMODULE module;
    if(
GetModuleHandleEx(0,(LPCSTR)"mp.dll",&module))
    {
        
HANDLE process =  GetCurrentProcess();
        
_MODULEINFO moduleInfo;
        
        if(
GetModuleInformation(process,module,&moduleInfo,sizeof moduleInfo))
        {
            
            
CloseHandle(process);

            
unsigned char baseAdress =  (unsigned char *) moduleInfo.lpBaseOfDll;
            
DWORD length moduleInfo.SizeOfImage;

            
            for(
unsigned int i=0<= length pLength ;i++)
            {
                if (
comparePattern(patternbaseAdress ipLength))
                {
                    
findet true;

                    
pathAddr baseAdress i;
                }
                
            }
        }

    }
    else
    {
        
SERVER_PRINT("Error locate module mp.dll");
        return 
false;
    }

    if (!
findet)
    {
        
SERVER_PRINT("Cant find patch!");
        return 
false;
    }

    
= (void (*)(int *))pathAddr;

    
memcpy((void *)originalBytespathAddr5);

    
pathedBytes[0] = 0xE9;
    *((
long*)(&pathedBytes[1])) = (char*)HooK_CheckWinCondition - (char*)pathAddr 5;

    
DWORD oldProtection;

    if(
VirtualProtect(pathAddr5PAGE_EXECUTE_READWRITE, &oldProtection))
        return 
true;

    return 
false;

__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-09-2013 , 18:47   Re: Patching memory
Reply With Quote #27

Quote:
But I do not understand how to not return the original function
Look, the way you hook, you redirect original call to your function in the module. By doing nothing, you block the original function. If you want to do stuffs and not blocking the original function, you would do insert your code, then after you would call the original function from it's real address. To block it, you simply don't call the original function from it's real address.
__________________

Last edited by Arkshine; 02-09-2013 at 18:56.
Arkshine is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 02-09-2013 , 19:00   Re: Patching memory
Reply With Quote #28

Thank you very much Arkshine!

I'll try to
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Bos93
Veteran Member
Join Date: Jul 2010
Old 02-10-2013 , 05:44   Re: Patching memory
Reply With Quote #29

roundTimeCheck - Block to the end, when the time is exactly zero?

I'm hook roundTimeCheck and time = 00:00 server crash ( not return the original function )

CheckWinCondition - Block to the end, when the team wins or a bomb explodes?
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Old 02-10-2013, 06:33
Bos93
This message has been deleted by Bos93.
Bos93
Veteran Member
Join Date: Jul 2010
Old 02-10-2013 , 06:42   Re: Patching memory
Reply With Quote #30

I'm hook CheckWinCondition

I'm write kill in console - Round is not over

it's worked

But otherwise the round ends
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Reply



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:31.


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