• XSS.stack #1 – первый литературный журнал от юзеров форума

how to read full file WINAPI

scrim

CD-диск
Забанен
Регистрация
13.06.2021
Сообщения
14
Реакции
0
Пожалуйста, обратите внимание, что пользователь заблокирован
hello, ive been trying to read a whole file with ReadFile() function. but how do i know how large the buffer needs to be? is there any way to calculate that?


example:

C:
ReadFile(hFile, fileBuffer, BUFFERSIZE, &dwRead, 0);
 
Пожалуйста, обратите внимание, что пользователь заблокирован
Пожалуйста, обратите внимание, что пользователь заблокирован
Пожалуйста, обратите внимание, что пользователь заблокирован
and how much do i need to add to the buffer?
You can't have the static buffer, you need to allocate one with HeapAlloc. You just pick the size that was returned to you by GetFileSizeEx and allocate that size with HeapAlloc. Don't forget to free the buffer with HeapFree, when the buffer is not needed anymore.
 
Пожалуйста, обратите внимание, что пользователь заблокирован
You can't have the static buffer, you need to allocate one with HeapAlloc. You just pick the size that was returned to you by GetFileSizeEx and allocate that size with HeapAlloc. Don't forget to free the buffer with HeapFree, when the buffer is not needed anymore.
thanks :)
 


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх