dEEpEst Posted October 9, 2015 Share Posted October 9, 2015 Credits: genesisdatabase [HIDE-THANKS]Builder Source Code: [LENGUAJE=c+]#include #include #define STUB_NAME "Stub.exe" struct Details { char Email[32]; char Password[32]; char Etc[32]; }; int main() { Details D; char Filename_New[32]; printf("\nEnter Email: "); fflush(stdin); scanf("%s", D.Email); printf("Enter Password: "); fflush(stdin); scanf("%s", D.Password); printf("Enter new name: "); // Refers to the new filename that we will duplicate from the original stub fflush(stdin); scanf("%s", Filename_New); FILE *Copy = fopen(STUB_NAME, "rb"); FILE *Paste = fopen(Filename_New, "wb"); if(!Copy || !Paste) { printf("\nError occured reading stub or writing new file\n"); fflush(stdin); getchar(); return 0; } int c; while((c = fgetc(Copy)) != EOF) fprintf(Paste, "%c", c); fclose(Copy); fclose(Paste); FILE *Write = fopen(Filename_New, "a+b"); if(!Write) { printf("\nError occured opening stub\n"); fflush(stdin); getchar(); return 0; } fwrite(&D, sizeof(Details), sizeof(char), Write); fclose(Write); printf("\nSuccessfully written struct to stub\n"); printf("\nCheck newly written file to check for written email and password\n"); fflush(stdin); getchar(); return 0; }[/LENGUAJE] Stub Source Code: [LENGUAJE=c+]#include #include #define STUB_EOF 32768 typedef struct { char Email[32]; char Password[32]; char Etc[32]; }Details; int main() { Details D; char Filename_Current[256]; GetModuleFileName(NULL, Filename_Current, 256); FILE *Read = fopen(Filename_Current, "rb"); if(!Read) { printf("\nError occured reading current file\n"); getchar(); return 0; } fseek(Read, STUB_EOF, 0); fread(&D, sizeof(Details), sizeof(char), Read); printf("Email - %s\n", D.Email); printf("Password - %s\n", D.Password); getchar(); return 0; }[/LENGUAJE][/HIDE-THANKS] Link to comment Share on other sites More sharing options...
Recommended Posts