VC中嵌入汇编

#include <stdio.h> void __stdcall TranslateBuffer(char *buf,unsigned count,unsigned char eChar) { __asm{ pushad mov esi,buf mov ecx,count mov al,eChar L1: xor [esi],al inc esi loop L1 popad } //asm } int main(int argc, char *argv[]) { if(argc < 3) { printf("Usage: encode infile outfile/n"); return -1; } const int BUFSIZE = 2000; char buffer[BUFSIZE]; unsigned int count; unsigned char encryptCode; printf("Encryption code [0-255]?/n"); scanf("%c",&encryptCode); FILE *inFile = fopen(argv[1],"r+b"); FILE *outFile = fopen(argv[2],"w+b"); printf("Reading %s and creating %s/n",argv[1],argv[2]); while(!feof(inFile)) { count = fread(buffer,1,BUFSIZE,inFile); TranslateBuffer(buffer,count,encryptCode); fwrite(buffer,1,count,outFile); } fclose(inFile); fclose(outFile); return 0; } //EncryptFile source.txt des.txt

你可能感兴趣的:(c,汇编,File,buffer,include,encryption)