| 452 | } |
| 453 | |
| 454 | bool ProcessAccessHelp::writeMemoryToFile(HANDLE hFile, LONG offset, DWORD size, LPCVOID dataBuffer) |
| 455 | { |
| 456 | DWORD lpNumberOfBytesWritten = 0; |
| 457 | DWORD retValue = 0; |
| 458 | DWORD dwError = 0; |
| 459 | |
| 460 | if ((hFile != INVALID_HANDLE_VALUE) && dataBuffer) |
| 461 | { |
| 462 | retValue = SetFilePointer(hFile, offset, NULL, FILE_BEGIN); |
| 463 | dwError = GetLastError(); |
| 464 | |
| 465 | if ((retValue == INVALID_SET_FILE_POINTER) && (dwError != NO_ERROR)) |
| 466 | { |
| 467 | #ifdef DEBUG_COMMENTS |
| 468 | Scylla::debugLog.log(L"writeMemoryToFile :: SetFilePointer failed error %u", dwError); |
| 469 | #endif |
| 470 | return false; |
| 471 | } |
| 472 | else |
| 473 | { |
| 474 | if (WriteFile(hFile, dataBuffer, size, &lpNumberOfBytesWritten, 0)) |
| 475 | { |
| 476 | return true; |
| 477 | } |
| 478 | else |
| 479 | { |
| 480 | #ifdef DEBUG_COMMENTS |
| 481 | Scylla::debugLog.log(L"writeMemoryToFile :: WriteFile failed - size %d - error %u", size, GetLastError()); |
| 482 | #endif |
| 483 | return false; |
| 484 | } |
| 485 | } |
| 486 | } |
| 487 | else |
| 488 | { |
| 489 | #ifdef DEBUG_COMMENTS |
| 490 | Scylla::debugLog.log(L"writeMemoryToFile :: hFile invalid"); |
| 491 | #endif |
| 492 | return false; |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | bool ProcessAccessHelp::writeMemoryToFileEnd(HANDLE hFile, DWORD size, LPCVOID dataBuffer) |
| 497 | { |