0.3.1.2 tag, fixes for attach on Windows

develop
Petr Mrázek 2010-04-13 14:18:09 +02:00
parent 81cf60c0e0
commit 4bcd653732
2 changed files with 15 additions and 6 deletions

@ -82,11 +82,21 @@ NormalProcess::NormalProcess(uint32_t pid, vector <memory_info *> & known_versio
// temporarily assign this to allow some checks
d->my_handle = hProcess;
d->my_main_thread = 0;
// read from this process
uint32_t pe_offset = readDWord(base+0x3C);
read(base + pe_offset , sizeof(pe_header), (uint8_t *)&pe_header);
read(base + pe_offset+ sizeof(pe_header), sizeof(sections) , (uint8_t *)&sections );
d->my_handle = 0;
try
{
uint32_t pe_offset = readDWord(base+0x3C);
read(base + pe_offset , sizeof(pe_header), (uint8_t *)&pe_header);
read(base + pe_offset+ sizeof(pe_header), sizeof(sections) , (uint8_t *)&sections );
d->my_handle = 0;
}
catch (exception &)
{
CloseHandle(hProcess);
d->my_handle = 0;
return;
}
// see if there's a version entry that matches this process
vector<memory_info*>::iterator it;
@ -356,7 +366,7 @@ void NormalProcess::readDWord (const uint32_t offset, uint32_t &result)
void NormalProcess::read (const uint32_t offset, uint32_t size, uint8_t *target)
{
if(ReadProcessMemory(d->my_handle, (int*) offset, target, size, NULL))
if(!ReadProcessMemory(d->my_handle, (int*) offset, target, size, NULL))
throw Error::MemoryAccessDenied();
}

@ -27,7 +27,6 @@ int main (void)
#endif
return 1;
}
cout << "Attached, DF should be suspended now" << endl;
getline(cin, blah);