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 


hooking send api?
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon Apr 06, 2009 3:37 am    Post subject: hooking send api? Reply with quote

i'm having trouble with hooking send api through an executable file
through a dynamic library it's all good (using virtualprotect and you're done)
but i guess it should be different through exe's ?
cuz they have their own memory space and not injected to the process's memory space?!?!
so does any1 have an idea how to remove the memory protection?
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Apr 06, 2009 4:16 am    Post subject: Reply with quote

VirtualProtectEx()
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: Mon Apr 06, 2009 4:26 am    Post subject: Reply with quote

omg i'm so dumb XD
thx Cool

@edit: a little problem here
to what process do i need to change the memory?
i mean the function is in ws2_32.dll but what process load that file?
Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Mon Apr 06, 2009 8:52 am    Post subject: Reply with quote

The same one that you usually inject dynamic library into.
Back to top
View user's profile Send private message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Mon Apr 06, 2009 8:46 pm    Post subject: Reply with quote

1qaz wrote:
omg i'm so dumb XD
thx Cool

@edit: a little problem here
to what process do i need to change the memory?
i mean the function is in ws2_32.dll but what process load that file?

You need to change the process that you are using. It'll only affect that process's memory space.
Back to top
View user's profile Send private message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Mon Apr 06, 2009 9:52 pm    Post subject: Reply with quote

Quote:
@edit: a little problem here
to what process do i need to change the memory?
i mean the function is in ws2_32.dll but what process load that file?


It depends. What process are you trying to intercept packets on?
Back to top
View user's profile Send private message AIM Address MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon Apr 06, 2009 10:32 pm    Post subject: Reply with quote

i'm trying to capture msn or icq packets
it's possible i know since i succeded doing it using dll
btw how do i get the base address of process?
i was thinking about
Code:

MEMORY_BASIC_INFORMATION mbi;
VirtualQueryEx(hProc,NULL,&mbi,sizeof(mbi));
// then i'll just pop it up from mbi.BaseAddress

but it keeps returning me null :\ any ideas?
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Tue Apr 07, 2009 11:18 am    Post subject: Reply with quote

Code:

ULONG ModBase = (ULONG)GetModuleHandle(0);


regards BanMe

_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.
Back to top
View user's profile Send private message MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue Apr 07, 2009 12:04 pm    Post subject: Reply with quote

oh Surprised i think u miss understand me
i asked how to get the base address of any process that i want
not the current process of my program Surprised
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Tue Apr 07, 2009 12:54 pm    Post subject: Reply with quote

oh sorry about that misinterpretation Wink

This code should work for any process..

Code:

#include <windows.h>
#include <tlhelp32.h>
DWORD UsrGetProcessBase(HANDLE hProcess,char*ProcessName)
{
   DWORD Pid = GetProcessId(hProcess);
   int tS = 0;
   BOOL tB = false;
   HANDLE hSnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS,Pid );
   MODULEENTRY32 ME;
   ME.dwSize = sizeof( MODULEENTRY32 );
   tB = Module32First( hSnapShot,&ME );
   if(!tB)
   {
      return 0;
   }
   while( Module32Next( hSnapShot,&ME ) != false)
   {
      tS = strcmp( ProcessName,ME.szModule );
      if(tS == 0)
      {
            CloseHandle(hSnapSho
            return ME.modBaseAddress;
      }
   }
   CloseHandle(hSnapShot);
   return 0;
}


this code can be more dynamic and the ProcessName parameter can be removed if we use ZwQueryInformationProcess with ProcessImageFileName as the PROCESSINFOCLASS then we can convert the Unicode string to ascii using wcstombs or you could cut out the latter step and use unicode API's Smile

kind regards BanMe

_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.
Back to top
View user's profile Send private message MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue Apr 07, 2009 12:58 pm    Post subject: Reply with quote

oh great that's awesome
never heard about memoryentry structure
thanks :]
@edit:
how does it return dword when mobBaseAddress is actually byte* ?
i tried returning byte* with the function but it keeps returning me the same address for every process
i think i missed something here :s ?!
Back to top
View user's profile Send private message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Tue Apr 07, 2009 3:28 pm    Post subject: Reply with quote

BanMe wrote:
Code:

ULONG ModBase = (ULONG)GetModuleHandle(0);


regards BanMe

You should use ULONG_PTR;

You could also get the PEB base then access IMAGEBASEADDRESS.
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Tue Apr 07, 2009 4:18 pm    Post subject: Reply with quote

first off fuck ULONG_PTR ..32 bit debuggers don't track 64 bit variables.. if you want that crap annoying you fine, use find replace..dont bother me with your "you should code this way" crap..
and 2nd off the PEB is accessible from the current process where as 1gaz wanted remote process information..though i agree it is a usable idea within the current process Smile

and im sorry 1gaz i didnt look hard enough at all aspects of MODULEENTRY32.. but the simple fix is to change ME.modBaseAddress to (ULONG)ME.hModule.. :]

regards BanMe

_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.
Back to top
View user's profile Send private message MSN Messenger
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Tue Apr 07, 2009 4:52 pm    Post subject: Reply with quote

BanMe wrote:
first off fuck ULONG_PTR ..32 bit debuggers don't track 64 bit variables.. if you want that crap annoying you fine, use find replace..dont bother me with your "you should code this way" crap..
and 2nd off the PEB is accessible from the current process where as 1gaz wanted remote process information..though i agree it is a usable idea within the current process Smile

and im sorry 1gaz i didnt look hard enough at all aspects of MODULEENTRY32.. but the simple fix is to change ME.modBaseAddress to (ULONG)ME.hModule.. :]

regards BanMe


Rofl you suggested using the PEB before from one of your post and now I can't, what are you a hypocrite. &Also I didn't see the OP wanted to debug, so stop your idiotic assumptions.

I didn't even read the thread fully, just go jump off a cliff please.
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Tue Apr 07, 2009 4:59 pm    Post subject: Reply with quote

@irwin actually no the code was left with intentional errors and shortfalls to make the OP apply some effort to understanding the code and have a better understanding of logic analysis. thanks for your support in the matter of "pointing out the obvious" but next time try to keep it to yourself...


@:... LOL!!!!! i suggested using the PEB when the circumstances fit the requirements(ie accessing the PEB from the Current Process..) i agree with the you in accessing the PEB to obtain Current Process Info but to obtain Remote Process info, accessing the PEB is inpractical and adds more headaches then its worth..but yea good job reading what i said..

regards BanMe

_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.


Last edited by BanMe on Tue Apr 07, 2009 5:06 pm; edited 1 time in total
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, 3  Next
Page 1 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