Hi, i have the following bit of C code which reads from a pipe and then should block but it never blocks
int pipe_fd;
int res;
int open_mode = O_RDONLY;
char buf[100];
int bytes_read = 0;
memset (buf, '\0', sizeof(buf));
pipe_fd = open(FIFO_NAME, open_mode);
if (access(FIFO_NAME, F_OK) == -1)
{
res = mkfifo(FIFO_NAME, 0777);
i...
Hi,
I'm currently learning how to write shellcode and get a GCC warning "assignment of incompatible pointer type". Why?
Greetings,
LM
char shellcode[] =
"\x31\xc0"
"\xb0\x01"
"\x31\xdb"
"\xcd\x80";
int main() {
void (*func)() = shellcode;
func();
return 0;
}
...
I am doing embedded software development. By nature, I have 3 different applications running simultaneously that are guaranteed to run in different ranges of virtual addresses, e.g.
App 1 runs on 0x10000000 - 0x20000000, App2 runs in 0x20000000 - 0x30000000 and so on.
Generally GDB seems to accept only one symbol definition file. But i...
Could you recommend me some books on C and C++, that would be suitable for a Java developer?
In JAVA most things look simple enough, and the Specification helps a lot but both C and C++ are full of features that make me dizzy. Not that I have absolutely no experience with C++, but it's far from enough.
I am especially interested in C bo...
If you want to call a C/C++ function from inline assembly, you can do something like this:
void callee() {}
void caller()
{
asm("call *%0" : : "r"(callee));
}
GCC will then emit code which looks like this:
movl $callee, %eax
call *%eax
This can be problematic since the indirect call will destroy the pipeline on older CPUs.
Sin...
how do v find a value in an integer is garbage or not???
...
Hello,
I'm using one 3rd party SDK which get hwnd (window handle) and paints something on my window. And i want to specify window painting region (left, right, top, bottom) ? How it's possible to do it ? I'm found WINAPI function SetWindowRgn, but it's not good for me because this function specify whole window region. I need specify jus...
I have defined the following struct to represent an IPv4 header (up until the options field):
struct IPv4Header
{
// First row in diagram
u_int32 Version:4;
u_int32 InternetHeaderLength:4; // Header length is expressed in units of 32 bits.
u_int32 TypeOfService:8;
u_int32 TotalLength:16;
// Second row in dia...
This is not homework. I'm just trying to learn :)
I'm on to K&R's Exercise 1-18
Write a program to remove trailing blanks and tabs from each line of input, and to delete entirely blank lines.
This is what I've came up with so far
#include <stdio.h>
#define MAXLINE 1000
int getline(char line[], int maxline);
void copy(char to[],...
Hello,
I'm looking for anyone interested in joining me to study the book Pro Android Games.
If anyone is interested, please reply. Thanks
...
Hi,
How do i sha1 a string or set of numbers in Objective c?
...
Hi all, I would like to know about the inbuilt library functions in C to build a complete packet(along with frame) and to send it over a network... Can any one upload the C code which does the above stuff... :)
...
Hi all,
I've developed a driver that is compiled for 32 bits system. The driver is unidriver based.
Does anyone knows what should be needed to get the driver compatible with 64 bits? What changes should I need to do to the code, if any? or is it just a matter of compiling it with a 64 bits version of the DDK?
Thanks in advance.
Nuno
...
I am trying to reverse a character string in C
Here is what I have
void reverse(char str[]) {
int i = 0;
int length;
// Get string length
for (i = 0; str[i] != '\0' ; ++i) {
length = i;
}
char reversed[1000];
int j;
j = 0;
// Reverse it
for (j = 0; j < length ; ++j) {
reversed[...
I want to write simple program in C equivalent to the regular expression:
/<rr>(.*?)<\/rr>/<test>$1<\/test>/gi.
Does anyone have examples?
...
Hii ,
I have been trying to write a program... We have a structure which has a rank field and the name field.The pointer to this structure is stored in an array of fixed size. I have implemented it as follows and i have certain problems...
The code i have written is :
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
typedef st...
Basically, I have key detection for my console application, for some reason it's not detecting function keys.
Here is my code, I'm using GNU compiler on linux. Any help or ideas would be greatly appreciated.
refresh();
key = getch();
switch(key) {
case KEY_HOME: key = HOME; break;
...
Like most professionals in the area of software development, I'm always open for learning new technologies/frameworks that might improve productivity. Relatively speaking, I'm still a novice in the area(3-4 years of experience) and my first contact with software development was in the .NET plataform with VB.NET language. At the time I ha...
I am using write() on a opened data socket in FTP implementation to send the file out. But after writing some data it is hanging for some time; and after that it is returning with Broken pipe error. any help in this will greatly appreciated. My process reads packets from one buff and writes in to the socket. I noticed this problem with i...
Sometimes, when using macros to generate code, it is necessary to create identifiers that have global scope but which aren't really useful for anything outside the immediate context where they are created. For example, suppose it's necessary to compile-time-allocate an array or other indexed resource into chunks of various sizes.
/* P...