Skip to content

Instantly share code, notes, and snippets.

@upsuper upsuper/convert.c
Last active May 29, 2018

Embed
What would you like to do?
解包暖暖环游世界中 picData_rw.db 文件的工具代码
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
if (argc < 3) {
printf("usage: %s inputfile outputfile\n", argv[0]);
exit(2);
}
FILE* fin = fopen(argv[1], "r");
if (!fin) {
perror(argv[1]);
exit(1);
}
FILE* fout = fopen(argv[2], "w");
if (!fout) {
perror(argv[2]);
exit(1);
}
unsigned char buf[4096];
size_t read;
while ((read = fread(buf, 1, sizeof(buf), fin)) > 0) {
for (int i = 0; i < read; i++)
buf[i] = ~buf[i];
fwrite(buf, 1, read, fout);
}
fclose(fin);
fclose(fout);
return 0;
}
#!/usr/bin/env python3
import sys
import sqlite3
from pathlib import Path
if len(sys.argv) < 3:
print("usage: {} database output".format(sys.argv[0]))
exit(2)
conn = sqlite3.connect(sys.argv[1])
output_dir = Path(sys.argv[2])
cur = conn.cursor()
for row in cur.execute("SELECT * FROM picData"):
print(row[0], end="... ")
if not isinstance(row[1], bytes):
print(row[1])
else:
with Path(output_dir, row[0] + '.png').open('wb') as f:
f.write(row[1])
print("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.