google-site-verification: googlebaca44933768a824.html CSS GetModuleBaseAdress Problem [c#] - Old Royal Hack Forum

Announcement

Collapse
No announcement yet.

CSS GetModuleBaseAdress Problem [c#]

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    CSS GetModuleBaseAdress Problem [c#]

    Hey,

    I?m trying to get the base adress of "engine.dll ", but for some reason my Method is unable to find the right dll, I always find dlls like "wow64.dll",wow64cpu.dll","ntdll.dll" and so on.
    Would be nice if anyone would take a look at my Method and tell me if I?m doing something wrong.

    *****Method
    private static IntPtr GetModuleBaseAddress(string AppName, string ModuleName)
    {
    IntPtr BaseAddress = IntPtr.Zero;
    Process[] myProcess = null;
    ProcessModule myProcessModule = null;

    myProcess = Process.GetProcessesByName(AppName);

    if (myProcess.Length > 0)
    {
    ProcessModuleCollection myProcessModuleCollection = myProcess[0].Modules;

    for (int i = 0; i < myProcessModuleCollection.Count; i++)
    {
    myProcessModule = myProcessModuleCollection[i];
    if (myProcessModule.ModuleName.Contains(ModuleName))
    {
    BaseAddress = myProcessModule.BaseAddress;
    break;
    }
    }
    }
    ****Method end

    #2
    Re: CSS GetModuleBaseAdress Problem [c#]

    push

    Comment


      #3
      Re: CSS GetModuleBaseAdress Problem [c#]

      doesn't look like you're returning anything. shouldn't vs have told you about that by now? so i'm wondering how do u find anything at all?

      edit: wrote a simple test case. works just fine.
      Code:
      using System;
      using System.Diagnostics;
      
      namespace GetModuleBaseExternTest {
          class Program {
              private static IntPtr GetModuleBaseExtern( Process process, String moduleName ) {
                  foreach( ProcessModule module in process.Modules ) {
                      if( module.ModuleName.Equals( moduleName ) ) {
                          return module.BaseAddress;
                      }
                  }
                  return IntPtr.Zero;
              }
      
              static void Main( string[] args ) {
                  Process[] foundProcesses = Process.GetProcessesByName( "hl2" );
                  if( foundProcesses.Length > 0 ) {
                      Process hl2Exe = foundProcesses[ 0 ];
                      Console.WriteLine( "found process: " + hl2Exe.ProcessName );
                      IntPtr moduleBase = GetModuleBaseExtern( hl2Exe, "engine.dll" );
                      if( !moduleBase.Equals( IntPtr.Zero ) ) {
                          Console.WriteLine( "found: engine.dll @ 0x" + moduleBase.ToString( "X" ) );
                      } else {
                          Console.WriteLine( "couldn't fine engine.dll!" );
                      }
                  } else {
                      Console.WriteLine( "couldn't fine hl.exe!" );
                  }
                  Console.ReadLine();
              }
          }
      }
      Last edited by b2k5; 02-02-2013, 08:49 PM. Reason: fixed format. fuck microsoft default.

      Comment


        #4
        Re: CSS GetModuleBaseAdress Problem [c#]

        Originally posted by b2k5 View Post
        doesn't look like you're returning anything. shouldn't vs have told you about that by now? so i'm wondering how do u find anything at all?
        I forgot to paste the last line of code, thats why.
        But this doesn?t mean I did any mistakes, I debugged everything step by step and the Problem is that I don?t find the dll?s I?m looking for.

        Comment


          #5
          Re: CSS GetModuleBaseAdress Problem [c#]

          i edited my previous post with a working solution.

          Comment


            #6
            Re: CSS GetModuleBaseAdress Problem [c#]

            Thanks for your help, but now I get an error:
            "Fehler 1 Der Name "GetModuleBaseExtern" ist im aktuellen Kontext nicht vorhanden" <--- Didn?t translate this because b2k5 is German :P.

            Comment


              #7
              Re: CSS GetModuleBaseAdress Problem [c#]

              The Error is pretty self-explanatory :-/ stop copy+pasting.

              Comment


                #8
                Re: CSS GetModuleBaseAdress Problem [c#]

                pwned hard kill urself now

                Comment


                  #9
                  Re: CSS GetModuleBaseAdress Problem [c#]

                  Originally posted by k3nny View Post
                  pwned hard kill urself now
                  Thanks for your shitty input wish i could still infract people.

                  Tom,
                  FUHRERS G0T HIS SWAGGA BACK

                  Comment

                  Working...
                  X