[C# - REQUEST] Process ID + DLL ??

10/21/2009 23:14 Pain1234#1
Hey guys,
i got following Problem:
I want to write a bot but the Memory values are in a dll of the process (game.dll) now i just dont know how to get the base of the dll. I got an AutoID example:

PHP Code:
Func MemReadDLLEnemyLevel($offset)
    
$StaticOffset Dec($offset)
    Global 
$pid
    
Global $CUROffset[1]
    
$CUROffset[0] = 0
    $baseADDR 
_MemoryModuleGetBaseAddress($pid"Game.dll")
    
$finalADDR "0x" Hex($baseADDR $StaticOffset)
    
$MemTest _MemoryRead($finaladdr,$openmem)
    
$MemTest _memoryread(   $MemTest0x01C4,$openmem)
    
$MemTest _memoryread(   $MemTest 0x0032$openmem,"byte" )
    Return 
$MemTest
EndFunc 
_MemoryModuleGetBaseAddress FUNC:
PHP Code:

Func _MemoryModuleGetBaseAddress
($iPID$sModule)
    If 
Not ProcessExists($iPIDThen Return SetError(100)

    If 
Not IsString($sModuleThen Return SetError(200)

    
Local   $PSAPI DllOpen("psapi.dll")

    ;
Get Process Handle
    Local   $hProcess
    Local   $PERMISSION 
BitOR(0x00020x04000x00080x00100x0020) ; CREATE_THREADQUERY_INFORMATIONVM_OPERATIONVM_READVM_WRITE

    
If $iPID 0 Then
        Local $hProcess 
DllCall("kernel32.dll""ptr""OpenProcess""dword"$PERMISSION"int"0"dword"$iPID)
        If 
$hProcess[0Then
            $hProcess 
$hProcess[0]
        EndIf
    EndIf

    ;
EnumProcessModules
    Local   $Modules 
DllStructCreate("ptr[1024]")
    
Local   $aCall DllCall($PSAPI"int""EnumProcessModules""ptr"$hProcess"ptr"DllStructGetPtr($Modules), "dword"DllStructGetSize($Modules), "dword*"0)
    If 
$aCall[4] > 0 Then
        Local   $iModnum 
$aCall[4] / 4
        Local   $aTemp
        
For $i 1 To $iModnum
            $aTemp 
=  DllCall($PSAPI"dword""GetModuleBaseNameW""ptr"$hProcess"ptr"Ptr(DllStructGetData($Modules1$i)), "wstr""""dword"260)
            If 
$aTemp[3] = $sModule Then
                DllClose
($PSAPI)
                Return 
Ptr(DllStructGetData($Modules1$i))
            EndIf
        
Next
    
EndIf

    
DllClose($PSAPI)
    Return 
SetError(-100)

EndFunc 
I just dont know how to do this in c#! Maybe you can help me