Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdint.h>
- #include <stdio.h>
- #include <windows.h>
- int main(int argc, char* argv[])
- {
- const size_t int_len = 4;
- HANDLE input_file = CreateFile(
- argv[1],
- GENERIC_READ,
- FILE_SHARE_READ,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- 0);
- DWORD file_size = GetFIleSize(input_file, NULL);
- if (file_size == 0) {
- goto finally_ok;
- }
- DWORD next_position = 0;
- int value = 0;
- bool is_ok = TRUE;
- is_ok = ReadFile(input_file, &value, sizeof(int), NULL, NULL);
- if (!is_ok) {
- goto finally_err;
- }
- printf("%d ", value);
- bool info_read =
- ReadFile(input_file, &next_position, sizeof(DWORD), NULL, NULL);
- if (!info_read) {
- goto finally_err;
- }
- while (next_position != 0) {
- SetFilePointer(input_file, next_position, NULL, FILE_BEGIN);
- ReadFile(input_file, &value, sizeof(int), NULL, NULL);
- printf("%d ", value);
- ReadFile(input_file, &next_position, sizeof(DWORD), NULL, NULL);
- }
- goto finally_ok;
- finally_err:
- CloseHandle(input_file);
- return 1;
- finally_ok:
- CloseHandle(input_file);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement