本文整理汇总了C++中writemem函数的典型用法代码示例。如果您正苦于以下问题:C++ writemem函数的具体用法?C++ writemem怎么用?C++ writemem使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writemem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rfc822
static void rfc822(FILE *fp, struct fetchinfo *fi,
struct imapscaninfo *info, unsigned long msgnum,
struct rfc2045 *rfcp)
{
unsigned long n=0;
int c;
char buf[BUFSIZ];
unsigned long i;
writes("RFC822 ");
if (fseek(fp, 0L, SEEK_SET) == -1)
{
fetcherror("fseek", fi, info, msgnum);
writes("{0}\r\n");
return;
}
while ((c=getc(fp)) != EOF)
{
++n;
if (c == '\n') ++n;
}
if (fseek(fp, 0L, SEEK_SET) == -1)
{
fetcherror("fseek", fi, info, msgnum);
writes("{0}\r\n");
return;
}
writes("{");
writen(n);
writes("}\r\n");
i=0;
while (n)
{
c=getc(fp);
if (c == '\n')
{
if (i >= sizeof(buf))
{
writemem(buf, i);
i=0;
}
buf[i++]='\r';
if (--n == 0) break;
}
if (i >= sizeof(buf))
{
writemem(buf, i);
i=0;
}
buf[i++]=c;
--n;
++body_count;
}
writemem(buf, i);
}
示例2: rfc822text
static void rfc822text(FILE *fp, struct fetchinfo *fi,
struct imapscaninfo *info, unsigned long msgnum,
struct rfc2045 *rfcp)
{
off_t start_pos, end_pos, start_body;
off_t nlines, nbodylines;
unsigned long i;
int c;
char buf[BUFSIZ];
unsigned long l;
writes("RFC822.TEXT {");
rfc2045_mimepos(rfcp, &start_pos, &end_pos, &start_body,
&nlines, &nbodylines);
if (fseek(fp, start_body, SEEK_SET) == -1)
{
fetcherror("fseek", fi, info, msgnum);
writes("0}\r\n");
return;
}
i=end_pos - start_body + nbodylines;
writen(i);
writes("}\r\n");
l=0;
while (i)
{
c=getc(fp);
if (c == EOF)
{
fetcherror("unexpected EOF", fi, info, msgnum);
_exit(1);
}
--i;
if (l >= sizeof(BUFSIZ))
{
writemem(buf, l);
l=0;
}
if (c == '\n' && i)
{
--i;
buf[l++]='\r';
if (l >= sizeof(BUFSIZ))
{
writemem(buf, l);
l=0;
}
}
buf[l++]=c;
++body_count;
}
writemem(buf, l);
}
示例3: writeqs
void writeqs(const char *s)
{
size_t i=strlen(s), j;
while (i)
{
for (j=0; j<i; j++)
{
if ( s[j] == '"' || s[j] == '\\')
{
writemem(s, j);
writemem("\\", 1);
writemem(s+j, 1);
++j;
s += j;
i -= j;
j=0;
break;
}
#if 0
if (s[j] == '&')
{
writemem(s, j);
writemem("&-", 2);
++j;
s += j;
i -= j;
j=0;
break;
}
if (s[j] < ' ' || s[j] >= 0x7F)
{
char *q;
writemem(s, j);
++j;
s += j;
i -= j;
for (j=0; j<i; j++)
if (s[j] >= ' ' && s[j] < 0x7F)
break;
q=imap_utf7_encode(s, j);
if (!q) write_error_exit(0);
writemem("&", 1);
writes(q);
writemem("-", 1);
s += j;
i -= j;
j=0;
break;
}
#endif
}
writemem(s, j);
s += j;
i -= j;
}
}
示例4: writen
void writen(unsigned long n)
{
char buf[40];
sprintf(buf, "%lu", n);
writemem(buf, strlen(buf));
}
示例5: cmd_writemem_run
static int
cmd_writemem_run( chain_t *chain, char *params[] )
{
uint32_t adr;
uint32_t len;
FILE *f;
if (cmd_params( params ) != 4)
return -1;
if (!bus) {
printf( _("Error: Bus driver missing.\n") );
return 1;
}
if (cmd_get_number( params[1], &adr) || cmd_get_number( params[2], &len))
return -1;
f = fopen( params[3], "r" );
if (!f) {
printf( _("Unable to open file `%s'!\n"), params[3] );
return 1;
}
writemem( bus, f, adr, len );
fclose( f );
return 1;
}
示例6: writemem
void L3G4200D::init( int scale) {
//From Jim Lindblom of Sparkfun's code
_dev_address = L3G4200D_Address;
// Enable x, y, z and turn off power down:
writemem(CTRL_REG1, 0b00001111);
// If you'd like to adjust/use the HPF, you can edit the line below to configure CTRL_REG2:
writemem(CTRL_REG2, 0b00000000);
// Configure CTRL_REG3 to generate data ready interrupt on INT2
// No interrupts used on INT1, if you'd like to configure INT1
// or INT2 otherwise, consult the datasheet:
writemem(CTRL_REG3, 0b00001000);
// CTRL_REG4 controls the full-scale range, among other things:
if(scale == 250){
writemem(CTRL_REG4, 0b00000000);
}else if(scale == 500){
writemem(CTRL_REG4, 0b00010000);
}else{
writemem(CTRL_REG4, 0b00110000);
}
// CTRL_REG5 controls high-pass filtering of outputs, use it
// if you'd like:
writemem(CTRL_REG5, 0b00000000);
}
示例7: writemem
BOOL cwindow::emptyscreen()
{
int i;
for(i = 1; i <= m_nmaxrows; i ++)
writemem(m_npage, i + m_nrow1, 0 + m_ncol1, '\0', (m_nmaxcols - 0) * 2);
m_nwritedrow = 1;
m_nactiverow = 1;
return TRUE;
}
示例8: printheader
static void printheader(struct fetchheaderinfo *fi, const char *p, size_t s)
{
size_t i;
if (fi->skipping)
{
if (fi->skipping > s)
{
fi->skipping -= s;
return;
}
p += fi->skipping;
s -= fi->skipping;
fi->skipping=0;
}
if (s > fi->cnt) s=fi->cnt;
for (i=0; i <= s; i++)
if (p[i] != '\r')
++header_count;
writemem(p, s);
fi->cnt -= s;
}
示例9: readmem
void ITG3200::setZgyroStandby(bool _Status) {
readmem(PWR_MGM, 1, &_buff[0]);
writemem(PWR_MGM, ((_buff[0] & PWRMGM_STBY_ZG) | _Status << 3));
}
示例10: writemem
void ITG3200::reset() {
writemem(PWR_MGM, PWRMGM_HRESET);
delay(GYROSTART_UP_DELAY); //gyro startup
}
示例11: main
int main(int argc, const char** argv)
{
while(running)
{
//fetch
int op = readmem(pc);
pc++;
//decode
int op_id = op >> 9;
int x = (op >> 6) & 7; //shift by 6, and take 3 bits (2^3-1 = 7)
//x & 0b000000111 (masking)
//0x -> hex
//0x0005_1234 <- nice formating
int y = (op >> 3) & 7; //bits 5 to 3
int z = (op >> 0) & 7; //bits 2 to 0
int imm = (op >> 0) & 63; //bits 5 to 0
switch(op_id)
{
case op_nop: //do nothing
break;
case op_add: // x <- y + z
reg[x] = reg[y] + reg[z];
break;
case op_shift: // x <- y << z
reg[x] = reg[y] << reg[z];
break;
case op_xor: // x <- y ^ z
reg[x] = reg[y] ^ reg[z];
break;
case op_read: // x <- readmem(y)
if ( z !=0 )
put("ERROR");
else
reg[x] = readmem(reg[y]);
break;
case op_write: // writemem(y,x)
if ( z !=0 )
put("ERROR");
else
writemem(reg[y],reg[x]);
break;
case op_print: //printf("%d",r[x])
if ( y !=0 || z !=0 )
put("ERROR");
else
printf("%d",reg[x]);
break;
case op_put: // putc(x)
if ( y !=0 || z !=0 )
put("ERROR");
else
put(reg[x]);
break;
case op_mov:
reg[x] = imm;
break;
}
}
}
示例12: main
int main(int argc, char *argv[])
{
if(argc != 2) { printf("Not correct argumento\n"); return 1; }
// sig is easy to find:
// first search for youtube.com in friendsui
// next, go to the array it's referenced in
// lastly click the xref of the array!
// the start of the function is what this sig is!
const char *sig = "\x55"
"\x57"
"\x56"
"\x53"
"\x83\xEC?"
"\xE8????"
"\x81?????"
"\x8B???"
"\x8D?????"
"\x8D?????"
"\xEB?"
"\x83\xC6\x04";
pid_t pid;
sscanf(argv[1], "%d", &pid);
char temp[256];
snprintf(temp, 256, "/proc/%i/mem", pid);
FILE *f = fopen(temp, "rb+");
char mem[1];
const char *now = sig;
memory mems;
int skip = 0;
while(GetMemory(&mems, argv[1], "friendsui.so",skip))
{
printf("%08lX - %08lX\n", mems.start, mems.end);
for(long i = mems.start; i < mems.end; i++)
{
if(!readmem(f, i, (void *)mem, 1))
{
printf("END!! :(: %08lX\n", i);
break;
}
if(*now == '?' || *now == mem[0])
{
now++;
if(!*now) // end of sig
{
long write = i - strlen(sig) + 1;
// mov eax, 1
// retn
if(!writemem(f, write, (void *)"\xB8\x01\x00\x00\x00\xC3", 6))
{
printf("NO WRITE!!\n");
}
printf("Found!!! %08lX\n", i);
break;
}
}
else
now = sig;
}
skip++;
}
fclose(f);
printf("Done!\n");
return 0;
}
示例13: dofetchheadersbuf
//.........这里部分代码省略.........
goodheader= (*headerfunc)(fi, "");
l=0;
for (j=0; j<i; )
{
if (buf[j] != '\n' && buf[j] != '\r' &&
!isspace((int)(unsigned char)buf[j]))
{
goodheader= (*headerfunc)(fi, "");
for (k=j; k<i; k++)
{
if (buf[k] == '\n' || buf[k] == ':')
break;
}
if (k < i && buf[k] == ':')
{
buf[k]=0;
goodheader=(*headerfunc)(fi, buf+j);
buf[k]=':';
}
}
else if (buf[j] == '\n')
goodheader=0;
for (k=j; k<i; k++)
if (buf[k] == '\n')
{
++k;
break;
}
if (goodheader)
{
while (j<k)
buf[l++]=buf[j++];
}
j=k;
}
buf[l++]='\n'; /* Always append a blank line */
cnt=l;
for (i=0; i<l; i++)
if (buf[i] == '\n') ++cnt;
skipping=0;
if (fi->ispartial)
{
skipping=fi->partialstart;
if (skipping > cnt) skipping=cnt;
cnt -= skipping;
if (fi->ispartial > 1 && cnt > fi->partialend)
cnt=fi->partialend;
}
writes("{");
writen(cnt);
writes("}\r\n");
p=buf;
while (skipping)
{
if (*p == '\n')
{
--skipping;
if (skipping == 0)
{
if (cnt)
{
writes("\n");
--cnt;
}
break;
}
}
--skipping;
++p;
}
while (cnt)
{
if (*p == '\n')
{
writes("\r");
if (--cnt == 0) break;
writes("\n");
--cnt;
++p;
continue;
}
for (i=0; i<cnt; i++)
if (p[i] == '\n')
break;
writemem(p, i);
p += i;
cnt -= i;
header_count += i;
}
}
示例14: debugger_do
//.........这里部分代码省略.........
for (c = 0; c < 8; c++)
{
if (watchr[c] != -1)
{
sprintf(outs, " Read watchpoint %i : %04X\n", c, watchr[c]);
debug_out(outs);
}
}
for (c = 0; c < 8; c++)
{
if (watchw[c] != -1)
{
sprintf(outs, " Write watchpoint %i : %04X\n", c, watchw[c]);
debug_out(outs);
}
}
}
if (!strncasecmp(ins, "wclearr", 7))
{
if (!params) break;
sscanf(&ins[d], "%X", &e);
for (c = 0; c < 8; c++)
{
if (watchr[c] == e) watchr[c] = -1;
if (c == e) watchr[c] = -1;
}
}
else if (!strncasecmp(ins, "wclearw", 7))
{
if (!params) break;
sscanf(&ins[d], "%X", &e);
for (c = 0; c < 8; c++)
{
if (watchw[c] == e) watchw[c] = -1;
if (c == e) watchw[c] = -1;
}
}
else if (!strncasecmp(ins, "writem", 6))
{
if (!params) break;
sscanf(&ins[d], "%X %X", &e, &f);
rpclog("WriteM %04X %04X\n", e, f);
writemem(e, f);
}
break;
case 'q': case 'Q':
setquit();
while (1);
break;
case 'h': case 'H': case '?':
sprintf(outs, "\n Debugger commands :\n\n");
debug_out(outs);
sprintf(outs, " bclear n - clear breakpoint n or breakpoint at n\n");
debug_out(outs);
sprintf(outs, " bclearr n - clear read breakpoint n or read breakpoint at n\n");
debug_out(outs);
sprintf(outs, " bclearw n - clear write breakpoint n or write breakpoint at n\n");
debug_out(outs);
sprintf(outs, " blist - list current breakpoints\n");
debug_out(outs);
sprintf(outs, " break n - set a breakpoint at n\n");
debug_out(outs);
sprintf(outs, " breakr n - break on reads from address n\n");
debug_out(outs);
sprintf(outs, " breakw n - break on writes to address n\n");
debug_out(outs);
sprintf(outs, " c - continue running indefinitely\n");
debug_out(outs);
sprintf(outs, " d [n] - disassemble from address n\n");
debug_out(outs);
sprintf(outs, " m [n] - memory dump from address n\n");
debug_out(outs);
sprintf(outs, " q - force emulator exit\n");
debug_out(outs);
sprintf(outs, " r - print 6502 registers\n");
debug_out(outs);
sprintf(outs, " r sysvia - print System VIA registers\n");
debug_out(outs);
sprintf(outs, " r uservia - print User VIA registers\n");
debug_out(outs);
sprintf(outs, " r crtc - print CRTC registers\n");
debug_out(outs);
sprintf(outs, " r vidproc - print VIDPROC registers\n");
debug_out(outs);
sprintf(outs, " r sound - print Sound registers\n");
debug_out(outs);
sprintf(outs, " s [n] - step n instructions (or 1 if no parameter)\n\n");
debug_out(outs);
sprintf(outs, " watchr n - watch reads from address n\n");
debug_out(outs);
sprintf(outs, " watchw n - watch writes to address n\n");
debug_out(outs);
sprintf(outs, " wclearr n - clear read watchpoint n or read watchpoint at n\n");
debug_out(outs);
sprintf(outs, " wclearw n - clear write watchpoint n or write watchpoint at n\n");
debug_out(outs);
sprintf(outs, " writem a v - write to memory, a = address, v = value\n");
debug_out(outs);
break;
}
示例15: readmem
void SAT_Gyro::setYgyroStandby(bool _Status) {
readmem(PWR_MGM, 1, &_buff[0]);
writemem(PWR_MGM, ((_buff[0] & PWRMGM_STBY_YG) | _Status << 4));
}