I have a C program. Within it, I would like to embed either a file or a pre-assigned variable. I would prefer a method that is platform independent.
I am using the data type "RSA" from <openssl/rsa.h>. I have a key file in PEM format, but I would like to embed an RSA object in the program instead. I tried creating a char array and then casting the pointer, but that caused some sort of illegal casting issue. I tried using memcpy but I haven't been able to get it working that way. What is the best way of going about this? Is it possible to read a file directly from a memory buffer?
Is there any way to read RAM memory directly. For say i want to access memory location 0x0100 to 0x120. How to do that. how to declare the variable, is it unsigned int. what is the type of read values it hex or ascii. how t cast it.
I'm writing a program that communicates with another program over TCP/IP. I need to assemble contiguous buffers of mixed data to send to the server. For example, one of the messages must contain multiple 32-bit integers and 64-bit floats, each in its own appropriate field. I also need to receive and decode similar buffers.
The Windows TCP function "send(socket s,char *buf, int len, flags)" takes a pointer to a character array to send. Likewise, the TCP function "recv(socket s,char *buf,int len,flags)" takes a pointer to a character array to fill. I've tried creating structures describing the send and receive messages, with the fields appropriately laid out. But the CODE::BLOCKS compiler complains when I try to hand send and recv the pointers to the structure variables. Am I on the right track, or is there a better way to do this?
I am trying to add some functionality to this project: [URL] ...
Under this [URL] ...
This latest comment based on;
host.data = (u_char *) "112.168.231.19:80"; for (i = 0; i < peer->name.len; i++) { peer->name.data[i] = host.data[i]; } or more simpler: peer->name.data = host.data;
States: "Because strings always require an extra memory buffer (and the burden of memory management) while primitive values like booleans and numbers don't."
Which makes sense since a boolean change (down/up) does actually changes a runtime value, however the string replacement shows via '/upstreams' that the value has changed but at runtime it is still using the old value.
So in short it looks like I do need a buffer to change the string value.
My question is why? if 'peer->down' works on a memory fragment where its value resides then why doesn't a 'peer->name.data = host.data' do the same thing? can this be done without a buffer? once you allocate memory and store host.data in to this where do I copy it to?
I have a data buffer project in Windows 7 x64 embedded OS (using Visual Studio 2008), that would work simply like that:
One writer application will send data (no network protocols, just procedure call on the same machine) to my app like 20 packages per second, each data packages will be approximately 3 MB size and comes with a timestamp tag.
My application will store each data item for 100 minutes and then remove. (So I can calculate the total size from beginnig no need for dynamic allocation etc...)
Meanwhile there will be up to 5 reader applications which will query data from my app via Timestamp tag and retreive data (no updates or deletitions on data by reader apps).
So since the data in my buffer app can grow over 50GB I don't think that shared memory is going to work for my case.
I'm thinking about using Boost Memory Mapped Files or Windows API Memory Mapped Files.
So theoratically I will crate a fixed size File on harddisk (lets say 50GB) and then map some portion to RAM write the data to this portion, if the reader applications wants to use the data which is mapped currently on memory, then they will use directly, otherwise they will map some other potion of the file to their address spaces and use from there...
My problem is I haven't use Map File concept at all and I'm not a C++ developer so I'm not very familiar with the language fundementals. I've searched tutorials of boost and msdn for windows as well but there is not too much code example.
So I don't know how to map some portion of the data to memory and manage it, also how to search data in file or memory according to the timestamp tag. Yes there are codes for creating files and mapping the whole file to memory but none for dividing it into regions, aligning or padding the data which I need for my case.
I want to send data from a laptop (windows 7, processor 2.60GHz) to a desktop (windows xp, processor 3.10GHz) using serial communication (using a USB to RS232 convertor). The WriteFile function is able to send the data from the laptop (NumberOfBytesWritten is correct). But on the desktop side, ClearCommError detects no data in the read buffer.
This is the relevant code in my desktop:
while(1) { ClearCommError(hPort,&dwErrors,&commStatus); if (commStatus.cbInQue != 0) ReadFile(hPort,&data,1,&dwBytesRead,NULL); Sleep(10); }
The if condition is never satisfied. The baudrate and other parameters in the DCB struct are the same on both sides.
The same code works when I write and read in the same system by shorting the RX and TX pins in the RS232 connector.
why I cannot get correct value for the third element in my struct?In the second file where I'm reading from memory I allocate some space. Is this incorrect in some way? I'm running this on a Linux machine.
I'm not sure if I should do this with malloc or a char array. What I need to do is create 4 methods to read and 4 to write to memory like this (and it has to be fast):
Code:
char GetByte(char* memory, int offset); uint16 GetInt16(char* memory, int offset); uint32 GetInt32(char* memory, int offset); char[] GetString(char* memory, int offset);
So basically memory is the malloced memory and the offset is the position I want to read at.
I'm not sure if there's already a way to do this and maybe I'm overlooking something.
i want to write a program that can access to variables and methods of another program. I ques for access to variables need to read memory, but about methods?how i can use methods and call them?
I decided I wanted to make a proper programming language with a virtual machine and bytecode. I used this tutorial: [URL] .....
As a starting point for my project. So far I have modified it to allow for 32-bit addressing so that I can theoretically use 4GB in my programs. Now the problem I'm having is creating the memory.
Question:
I'm not sure if I should do this with malloc or a char array. What I need to do is create 4 methods to read and 4 to write to memory like this (and it has to be fast):
char GetByte(char* memory, int offset); uint16 GetInt16(char* memory, int offset); uint32 GetInt32(char* memory, int offset); char[] GetString(char* memory, int offset);
So basically memory is the malloced memory and the offset is the position I want to read at.
I am doing a project which I have to read, write and erase data from a NorFlash Memory. Then, I have to compare those data files in order to find errors.
Besides, I would like to know which is the best way to TEST errors in this kind of memories.
I am using NetBeans 7.3.1 for writting the code and Cygwin running on Windows XP Virtual Machine. The Memory Flash (S29JL064J 64 Megabit) is incorporated on an external board which is connected to an adapter board (using HDMI cable). This adapter is connected to the Laptop (using an USB).
I have two from in visual studio 2010 with C#. In form1 I have one combobox and one button .In form2 I have Reportviewer . When Button in form1 is clicked form2 is shown. Now my problem is when I click button to show form2 on the line Form2.Show(); this error appear : Attempted to read or write protected memory. This is often an indication that other memory is corrupt. What can i do? In form1 I have one combobox that combo fill with Database with this code in the Form Load:
I am parsing a binary data file by casting a buffer to a struct. It seems to work really well apart from this one double which is always being accessed two bytes off, despite being in the correct place.
If I attempt to print GROSS using printf("%f", row->GROSS) I get 0.0000. However, if I change the type of GROSS to char[8] and then use the following code, I am presented with the correct number...
Code:
typedef struct example { double d; }
example; example *blah = (example*)row->GROSS; printf("%f", blah->d);
I have CAN Dll program for my application,which was separately used.Now I have included the Drivers program into my application Program and I am having this error System Access Violation Exception:Attempted to read or write protected memory.i am attaching the Dll code and Application code which is throwing this error.
My Application Code which is the receiver thread for accessing the messages got onto the CAN bus.
DWORD WINAPI Rcv_Msg(LPVOID param){ int*MsgId = new int;//msg id from CAN intRcvVal;//0 = there is data in the queue; 1 = there is no data unsigned int uMsgId; *MsgId = 0; unsigned char CanData[8];
I'm successfully publishing an app to my website by publishing locally and then uploading the files but one of the options offered is to publish straight to the web site but I can't find anywhere to enter a user name and password for my web site. I could also do it with ftp but since the option is offered to publish directly to the web site I'd like to try that method. I'm using the Click Once method.
I wish to convert a character directly to a string for a top-secret project I'm working on. It needs to be portable across various machines with different sized Indians.
Code:
#include <stdio.h> int main(void) { const int i = 0x0041; const char *str_p = (char *) &i; }
[code]....
I want this to output an 'A', but I'm not sure this code will work on my friend's mom's S/360.
I don't know how to put this really, but I finished a program in Qt, and i want to know how to make a .exe file for it, so i dont have to open Qt and build the program every time i use it.
I've got two classes, which are both derived from the same two base classes. Here's a representation of the actual code:
Code: #include <vector> class BaseClassA { }; class BaseClassB { }; class TestClassX : public BaseClassA, public BaseClassB
[code].....
Basically, I'd like to know if it is possible to cast directly from a BaseClassA pointer to a BaseClassB pointer, without casting to the child class first.
I'm learning OpenGL using the C API and some of the functions' argument types have proven a bit challenging to me.
One example is the function Code: glShaderSource(GLuint shader, GLsizei count, GLchar const** string, GLint const* length); It resides in foo() which receives a vector "data" from elsewhere Code: void foo(std::vector<std::pair<GLenum, GLchar const*>> const& data); To pass the pair's second element to glShaderSource's third argument, I do the following:
1. Can I initialize a char const** via initialization list, the way I do a char const*?
Code:
// this works std::vector<std::pair<GLenum, GLchar const*>> const shader_sources = { {GL_VERTEX_SHADER, "sourcecode"}, {GL_FRAGMENT_SHADER, "sourcecode"} }; // but is this possible?
Is it possible to create a dynamic char array on the fly directly from stdin? I do not want to create a fixed length array before hand and then copy contents of it into a malloc created array.
Code: //[1] char line[MAX1]; gets(line);
[Code]....
I could do either [1](buffer overflow problem) or [2] and then goto [3]. But both will have a problem if the input is more than the size MAX1(use defined).
Is it possible to do something of the effect of readLine() method of BufferedReader class in Java or the Console.readLine in .NET? Is it possible to peek into stdin and see the size of the input and then creat an array of the same exact size?
Exporting the data from the sql database to excel directly.this code is not working and i am not getting file in particular location. My connection string is :
Data Source=aswin-pcsqlexpress;Initial Catalog=pro;Integrated Security=True
using Excel=Microsoft.Office.Interop.Excel; using System.Runtime.InteropServices; namespace WindowsFormsApplication5 { public partial class Form1 : Form { SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["SqlCon"].ToString());
I want to read the contents of a file block (512 bytes) by block using low I/O read statements. Each record is 64 bytes long and has a pre-defined structure. The first 4 bytes are an unsigned integer; the next 20 bytes are ascii text, etc.
I have a buffer which I can access with buf[0] to buf[63] to read the first record and then buf[64] to buf[127] for the second, etc. However, I was wondering how to map a record so that I can refer to an integer as an integer and a float as float, etc. I can't create a struct and move the 64 bytes to it, as I will have alllignment/padding problems.
What is the standard way to deal with records in C?