Notice
Recent Posts
Recent Comments
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- pytest
- 포인터 매핑
- NumPy Unicode Error
- TensorFlow
- commandline
- x64
- error
- hex-rays
- idapython
- mock.patch
- Python
- data distribution
- h5py.File
- idapro
- Rat
- ida pro
- malware
- debugging
- ecma
- Injection
- ida
- MySQL
- Ransomware
- why error
- svn update
- Analysis
- open office xml
- error fix
- javascript
- idb2pat
Archives
- Today
- Total
13 Security Lab
[API] SetEndOfFile(), Set "EOF" where Current FilePointer indicates 본문
Computer Science/Programming
[API] SetEndOfFile(), Set "EOF" where Current FilePointer indicates
Maj0r Tom 2014. 4. 15. 23:40http://msdn.microsoft.com/en-us/library/windows/desktop/aa365531(v=vs.85).aspx
Do refer MSDN, It's enough to understand.
"It works only when you got handle using CreateFile()"
typedef uint64_t fsize_t;
int file_resize(const char* path, fsize_t newsize)
{
HANDLE hFile = CreateFile(path, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE) return -1;
LARGE_INTEGER liDistanceToMove;
liDistanceToMove.QuadPart = (LONGLONG) newsize;
BOOL success;
success = SetFilePointerEx(hFile, liDistanceToMove, NULL, FILE_BEGIN);
if (success)
success = SetEndOfFile(hFile);
CloseHandle(hFile);
return (success) ? 0 : -1;
}
Comments