Try to reduce AV false-positives

This commit is contained in:
Florian Bach 2022-01-05 21:40:13 +01:00
parent 4dfa2194b8
commit 964d4c06eb
3 changed files with 10 additions and 6 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
/calibre-plugin/*.zip
/calibre-plugin/keyextract/*.exe
/calibre-plugin/module_id.txt
/calibre-plugin/module_id.txt
/calibre-plugin/__pycache__

View File

@ -5,7 +5,7 @@ clean:
rm decrypt_win32.exe decrypt_win64.exe 2>/dev/null || /bin/true
decrypt_win32.exe: main.c Makefile
i686-w64-mingw32-gcc main.c -Os -o decrypt_win32.exe -lcrypt32
i686-w64-mingw32-gcc main.c -O2 -o decrypt_win32.exe -lcrypt32
i686-w64-mingw32-strip decrypt_win32.exe
decrypt_win64.exe: main.c Makefile

View File

@ -19,7 +19,7 @@ int char2int(char input) {
if (input >= 'a' && input <= 'f')
return input - 'a' + 10;
printf("PROGOUTPUT:-3");
fputs("PROGOUTPUT:-3", stdout);
exit(-3);
}
@ -119,7 +119,7 @@ int main() {
char * entropy_hex = getenv(var_entropy);
if (data_hex == NULL || entropy_hex == NULL) {
printf("PROGOUTPUT:-1");
fputs("PROGOUTPUT:-1", stdout);
exit(-1);
}
@ -127,7 +127,7 @@ int main() {
char * entropy_bytes = malloc((strlen(entropy_hex) / 2));
if (data_bytes == NULL || entropy_bytes == NULL) {
printf("PROGOUTPUT:-2");
fputs("PROGOUTPUT:-2", stdout);
exit(-2);
}
@ -153,6 +153,7 @@ input_data.cbData = strlen(data_hex)/2;
entropy_data.pbData = entropy_bytes;
entropy_data.cbData = strlen(entropy_hex)/2;
int ret = CryptUnprotectData(
&input_data,
NULL,
@ -162,13 +163,15 @@ int ret = CryptUnprotectData(
0,
&output_data);
if (ret) {
if (output_data.cbData != 16) {
printf("PROGOUTPUT:-5:%d", output_data.cbData);
exit(-5);
}
// Success! Return decrypted data
printf("PROGOUTPUT:0:");
fputs("PROGOUTPUT:0:", stdout);
for (int i = 0; i < 16; i++) {
printf("%02x", output_data.pbData[i]);
}