/** Driver unload routine */ void EVhdDriverUnload(PDRIVER_OBJECT pDriverObject) { UNREFERENCED_PARAMETER(pDriverObject); if (g_shimFileHandle) { ZwClose(g_shimFileHandle); g_shimFileHandle = NULL; } Log_Cleanup(); DPT_Cleanup(); }
static void *Log_Thread(void *data) { struct log *log; char date[1024]; char buffer[8192]; struct log_entry *e, *ne; struct tm *tm; FILE *f; int i; log = (struct log *) data; if (!log) return NULL; //open the files snprintf(buffer, sizeof(buffer), "%smain", log->log_dir); log->main = fopen(buffer, "wa"); if (log->main == NULL) { Print_Console("could not open logfile: %s\n", buffer); } snprintf(buffer, sizeof(buffer), "%slua", log->log_dir); log->lua = fopen(buffer, "wa"); if (log->lua == NULL) { Print_Console("could not open logfile: %s\n", buffer); } snprintf(buffer, sizeof(buffer), "%sdebug", log->log_dir); log->debug = fopen(buffer, "wa"); if (log->debug == NULL) { Print_Console("could not open logfile: %s\n", buffer); } while (1) { if (log->run == false) if (log->first == log->last) break; e = log->first; while (e) { ne = e->next; if (!e->done) { tm = localtime(&e->time); strftime(date, sizeof(date), "%T", tm); if (e->type == log_main) f = log->main; else if (e->type == log_lua) f = log->lua; else if (e->type == log_debug) f = log->debug; else f = NULL; if (f) { i = strlen(e->string); i--; if (i) if (e->string[i] == '\n') e->string[i] = '\0'; fprintf(f, "%s: %s\n", date, e->string); fflush(f); } e->done = true; } if (e != log->last) { if (e->done) { if (e == log->first) log->first = ne; free(e->string); free(e); } } e = ne; } usleep(10000); } Log_Cleanup(log); return NULL; }