I guess I can just put this up. Most of these have been sitting here forever.

This commit is contained in:
Marisa the Magician 2017-09-04 11:24:40 +02:00
commit d2777092d1
26 changed files with 5347 additions and 0 deletions

37
memwr.c Normal file
View file

@ -0,0 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#define BUFSZ 8192
int main( int argc, char** argv )
{
if ( argc < 3 )
{
fputs("usage: memwrite <pid> <offset> <size>\n",stderr);
return 1;
}
char fn[256];
snprintf(fn,256,"/proc/%s/mem",argv[1]);
int fd = open(fn,O_WRONLY);
if ( !fd )
{
perror("could not open process");
return 2;
}
off_t memofs = 0;
off_t siz = 0, srd;
sscanf(argv[2],"%llx",&memofs);
sscanf(argv[3],"%lld",&siz);
lseek(fd,memofs,SEEK_SET);
unsigned char buf[BUFSZ];
while ( siz > 0 )
{
srd = read(0,buf,(siz>BUFSZ)?BUFSZ:siz);
write(fd,buf,srd);
siz -= srd;
}
close(fd);
return 0;
}