Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <windows.h>
- typedef struct Item
- {
- INT value;
- UINT next_pointer;
- } item_t;
- int
- main(int argc, char *argv[])
- {
- item_t current_item;
- INT fd = -1, exit_code = 0;
- if (argc < 2) {
- exit_code = 1;
- goto main_end;
- }
- INT item_count = 0;
- HANDLE h_file = CreateFileA(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (h_file == INVALID_HANDLE_VALUE) {
- exit_code = 1;
- goto main_end;
- }
- DWORD dw_count;
- while (ReadFile(h_file, ¤t_item, sizeof(item_t), &dw_count, NULL)) {
- item_count++;
- LARGE_INTEGER d_to_move;
- d_to_move.QuadPart = current_item.next_pointer;
- SetFilePointerEx(h_file, d_to_move, NULL, FILE_BEGIN);
- printf("%d ", current_item.value);
- }
- if (item_count != 0) {
- printf("%d ", current_item.value);
- }
- main_end:
- CloseHandle(h_file);
- return exit_code;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement