interdpth
I've seen things, man.
- 275
- Posts
- 20
- Years
- Seen Jun 8, 2021
Open up VC++ or any other C/C++ compiler make a new commandline project
open a blank c/cpp file paste this into it
#include <stdio.h>//Basic headers I always use
#include <windows.h>
int main(){
FILE *fp = NULL;// The file we'll be workin with
char FilePath[512]={0};//The zero is to make sure it's all zeroed out otherwise there could be weird values this is an array BTW
unsigned char Var1=0;//Our 8 bit variable set it to zero read above
unsigned short Var2=0;//unsigned is for values 0 to other stuff no negatives
unsigned long Var3=0;
printf("This program will grab a\n 8 bit variable, a 16 bit variable, a 32 bit variable\n"); // \n tells it to go to a new line
while(1){ // Infinite loop
printf("Please enter a file path\n");
scanf("%s",FilePath);//It knows to expect a string for input
fp = fopen(FilePath,"r+b");//Open for reading and writing to binary
if(fp){//Check to make sure the file opening succeeded
fseek(fp,5,SEEK_SET);//Hop to offset 5
Var1=fgetc(fp);
fread(&Var2,2,1,fp);
fread(&Var3,4,1,fp);
printf("Var1: 0x%X\n",Var1);//Print in hexadecimal output
printf("Var2: 0x%X\n",Var2);
printf("Var3: 0x%X\n",Var3);
printf("Yay we made it thus far,\nnow on each line please input a new value in hexadecimal output\n");
scanf("%8x",&Var1);//read from the commandline
scanf("%16x",&Var2);
scanf("%32x",&Var3);
printf("You entered for Var1: 0x%X\n", Var1);
printf("You entered for Var2: 0x%X\n", Var2);
printf("You entered for Var3: 0x%X\n", Var3);
printf("Now inserting into ROM\n");
fseek(fp,5,SEEK_SET);
fputc(Var1, fp);
fwrite(&Var2,2,1,fp);
fwrite(&Var3,4,1,fp);
fclose(fp);
}else{
printf("File opening failed");
}
printf("Ok, we're done please type 0 to exit anything else will restart the program\n");
scanf("%d",Var1);
if(Var1==0) return 0;
}
return 0;
}
compile it and run it
i'll do a basic windows application later
enjoy =p
open a blank c/cpp file paste this into it
#include <stdio.h>//Basic headers I always use
#include <windows.h>
int main(){
FILE *fp = NULL;// The file we'll be workin with
char FilePath[512]={0};//The zero is to make sure it's all zeroed out otherwise there could be weird values this is an array BTW
unsigned char Var1=0;//Our 8 bit variable set it to zero read above
unsigned short Var2=0;//unsigned is for values 0 to other stuff no negatives
unsigned long Var3=0;
printf("This program will grab a\n 8 bit variable, a 16 bit variable, a 32 bit variable\n"); // \n tells it to go to a new line
while(1){ // Infinite loop
printf("Please enter a file path\n");
scanf("%s",FilePath);//It knows to expect a string for input
fp = fopen(FilePath,"r+b");//Open for reading and writing to binary
if(fp){//Check to make sure the file opening succeeded
fseek(fp,5,SEEK_SET);//Hop to offset 5
Var1=fgetc(fp);
fread(&Var2,2,1,fp);
fread(&Var3,4,1,fp);
printf("Var1: 0x%X\n",Var1);//Print in hexadecimal output
printf("Var2: 0x%X\n",Var2);
printf("Var3: 0x%X\n",Var3);
printf("Yay we made it thus far,\nnow on each line please input a new value in hexadecimal output\n");
scanf("%8x",&Var1);//read from the commandline
scanf("%16x",&Var2);
scanf("%32x",&Var3);
printf("You entered for Var1: 0x%X\n", Var1);
printf("You entered for Var2: 0x%X\n", Var2);
printf("You entered for Var3: 0x%X\n", Var3);
printf("Now inserting into ROM\n");
fseek(fp,5,SEEK_SET);
fputc(Var1, fp);
fwrite(&Var2,2,1,fp);
fwrite(&Var3,4,1,fp);
fclose(fp);
}else{
printf("File opening failed");
}
printf("Ok, we're done please type 0 to exit anything else will restart the program\n");
scanf("%d",Var1);
if(Var1==0) return 0;
}
return 0;
}
compile it and run it
i'll do a basic windows application later
enjoy =p
Last edited by a moderator: