Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <stdint.h>
- union value {
- int i32;
- char buffer[4];
- } value;
- union next_pointer {
- uint32_t ui32;
- char buffer[4];
- } next_pointer;
- int main(int argc, char **argv) {
- HANDLE in = CreateFileA(argv[1], GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- BOOL result;
- DWORD counts;
- result = ReadFile(in, &value.buffer, sizeof(value.buffer), &counts, NULL);
- if (!result || counts != sizeof(value.buffer)) {
- goto finally;
- }
- result = ReadFile(in, &next_pointer.buffer, sizeof(next_pointer.buffer), &counts, NULL);
- if (!result || counts != sizeof(next_pointer.buffer)) {
- goto finally;
- }
- printf("%d ", value.i32);
- LARGE_INTEGER pointer;
- while (next_pointer.ui32 != 0) {
- pointer.QuadPart = next_pointer.ui32;
- result = SetFilePointerEx(in, pointer, NULL, FILE_BEGIN);
- if (!result) {
- goto finally;
- }
- result = ReadFile(in, &value.buffer, sizeof(value.buffer), &counts, NULL);
- if (!result || counts != sizeof(value.buffer)) {
- goto finally;
- }
- result = ReadFile(in, &next_pointer.buffer, sizeof(next_pointer.buffer), &counts, NULL);
- if (!result || counts != sizeof(next_pointer.buffer)) {
- goto finally;
- }
- printf("%d ", value.i32);
- }
- finally:
- CloseHandle(in);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement