read bit.db, malloc 4gb - hbb - hyperbitblock
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit ee392dbefab96dd2dbe63530e7e068de0ec1d026
DIR parent 236aeac8518d659825c5467887e747585508098a
HTML Author: kroovy <me@kroovy.de>
Date: Thu, 24 Apr 2025 00:14:48 +0200
read bit.db, malloc 4gb
Diffstat:
M hyperbitblock.c | 46 +++++++++++++++++++++----------
1 file changed, 32 insertions(+), 14 deletions(-)
---
DIR diff --git a/hyperbitblock.c b/hyperbitblock.c
@@ -3,6 +3,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/uio.h>
@@ -11,11 +12,15 @@
#include <ctype.h>
#include <fcntl.h>
-int is_bit_set(unsigned value, unsigned bitindex) {
+int
+is_bit_set(unsigned value, unsigned bitindex)
+{
return (value & (1 << bitindex)) != 0;
}
-int str_to_ip(char *s, uint8_t *v4) {
+int
+str_to_ip(char *s, uint8_t *v4)
+{
uint8_t oct=0;
int i,j;
@@ -37,24 +42,32 @@ int str_to_ip(char *s, uint8_t *v4) {
return 0;
}
-// uint8_t v4[] = {
-//
-// 0b00000000 /* 18 */
-// , 0b00010000 /* 119 */
-// , 0b01001000 /* 9 */
-// , 0b10101011 /* 193 */
-// };
-
-int main(void) {
+int
+main(void)
+{
int fd;
- int i, res;
+ FILE* db;
+ int i, res, ret=1;
uint8_t v4[4] = {0,0,0,0};
+ uint8_t* arr = malloc(4294967296);
uint32_t i32 = 0;
char c;
char line[64];
fd = open("mynamedpipe", O_RDWR);
+ db = fopen("bit.db", "r");
+
+ int cnt=0;
+ while (ret > 0) {
+ ret = fread(arr, 1024, 1, db);
+ cnt++;
+ }
+
+ //set some values
+ arr[1067179] = 255;
+ arr[309791169] = 255;
+ arr[3663462608] = 255;
nextline:
for (i=0; (res = read(fd, &c, 1)) > 0; i++) { //consider readline/getline
@@ -65,11 +78,16 @@ nextline:
}
c = '\0';
}
+ if (strncmp(line, "q", 1) == 0) {
+ free(arr);
+ return 0;
+ }
+
str_to_ip(line, v4);
i32 = (v4[0] << 24) | (v4[1] << 16) | (v4[2] << 8) | v4[3];
- printf("My IP is: %u.%u.%u.%u | ",v4[0],v4[1],v4[2],v4[3]);
- printf("That calculates to: %u\n",i32);
+ printf("%u.%u.%u.%u\t-->\t%u\t-->\t%u\n",v4[0],v4[1],v4[2],v4[3],i32,arr[i32]);
goto nextline;
close(fd);
+ fclose(db);
}