hi ich bin grade dabe einen Bot zu schreiben, dieser besteht um einem teil aus 2 in c++ geschribenen dlls(ohne .NET) und zum andernen teil aus einer in c# geschribenen .exe. In meinem c++ code nutze ich die funktion :
PHP Code:
c++:
VirtualAllocEx( hProcess, NULL, sizeof(szLibPath), MEM_COMMIT, PAGE_READWRITE )
PHP Code:
unsigned int StartThread(long ProcessID)
{
HANDLE hproc = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, 0,ProcessID);
if(hproc == 0){
MessageBox(0,L"OpenProcess Failed",0,0);
return (int)hproc;
}
MessageBox(0,L"OpenProcess Done",0,0);
return DoIt(hproc);
}
int DoIt( HANDLE hProcess )
{
HANDLE hThread;
char szLibPath [MAX_PATH];
void* pLibRemote = 0; // the address (in the remote process) where
// szLibPath will be copied to;
DWORD hLibModule = 0; // base adress of loaded module (==HMODULE);
HMODULE hKernel32 = ::GetModuleHandle(L"Kernel32");
MessageBox(0,L"GetModuleHandle Done",0,0);
// Get full path of "Remote.dll"
if( !GetModuleFileNameA( hMod,szLibPath,MAX_PATH) )
return false;
MessageBox(0,L"GetModuleFileNameA Done",0,0);
char * a = strstr(szLibPath,".exe");
strcpy( strstr(szLibPath,"StartLib.exe"),".dll" );
// 1. Allocate memory in the remote process for szLibPath
// 2. Write szLibPath to the allocated memory
pLibRemote = ::VirtualAllocEx( hProcess, NULL, sizeof(szLibPath), MEM_COMMIT, PAGE_READWRITE );
MessageBox(0,L"VirtualAllocEx Done",0,0);
if( pLibRemote == NULL )
return false;
.... und noch mehr code
die letzte Messagebox hat die nachricht "GetModuleFileNameA Done" das ist der Grund warum ich denke, dass der Feher von VirtualAllocEx ausgelöst wird
, die Memory in einem anderen Prozess alloziert, das funzt eig auch ganz gut. aber wenn ich versuche meinen selbstgeschriebene Funktion, die VirtualAllocEx benutzt, mittlens
PHP Code:
c#:
[DllImport(DllName)]
public unsafe static extern Int32 StartThread(//eine selbst geschribene Funktion in einer selbstgeschriebenen Datei, die VirtualAllocEx benuzt
long processID
);
von c# aus auzurufen bekommt ich eine exception des typs AccessViolationException
"Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist."
kann mir da jmd weiterhelfen?