C :: Write At Random Memory Locations

Jan 29, 2014

I have a complex program, around 25.000 code lines. It is quite stable, but I have a bug which only happens from time to time, and when in online-mode, so it is quite difficult for me to reproduce it. I have put lot of efforts to see where the problem is, and I have seen where the code crash, but that line is not the culprit, it only refers to read a memory location where it is supposed to be good data, and it is not. The real bug has happens before in execution. That data is read-only, I mean, I only compute it at program start-up, and then never write into it again, but my bug write to it doring code run, maybe because bad pointers address in any place, and look ramdom (different snapshots execution write at different memory locations).

My question is, is there a way to know when my code 'write' into that 'to me protected memory'? I thinking if there is a method to make a hash of all variables and arrays in that memory section, or any way to 'assert' when that big memory section is written, taking into accound that when I refer to that memory section it could be any of the lots of variables and arrays I precompute at start-up.

View 2 Replies


ADVERTISEMENT

C :: Tictactoe X And O Locations

Jan 26, 2013

I've made a tictactoe game using ncurses functions such as mvaddch to put x and o on my board. I need to somehow find the locations of the x's and o's so that i can win my game.

View 10 Replies View Related

C :: Locations In The RAM Addressed Per Word Or Per Byte?

Sep 20, 2014

Are locations in the RAM addressed per word or per byte? I am using a 32 bit machine, so I think that it means that on my PC a word would be 4 bytes.

View 11 Replies View Related

C++ :: Write Process Memory Bytes

Apr 8, 2014

Writing bytes to external process to remove a detour that the program does

this is what im trying it fails

HANDLE Handle = OpenProcess(PROCESS_ALL_ACCESS, false, ProcessId);

BYTE btLdrLoadDll[] = { 0x8B, 0xFF, 0x55, 0x8B, 0xEC };

if (!WriteProcessMemory(Handle, (BYTE*)((DWORD)GetProcAddress(GetModuleHandle("ntdll.dll"), "LdrLoadDll")), &btLdrLoadDll, sizeof(btLdrLoadDll), NULL)) {
CloseHandle(Handle);
std::cout << "
Failed to write Bytes to memory. Press enter to exit.";

[Code] ....

an also using the right address like this fails

WriteProcessMemory(Handle, (BYTE*)0x77C64F9F, &btLdrLoadDll, sizeof(btLdrLoadDll), NULL)

View 8 Replies View Related

C/C++ :: Write Random Grades To File?

Jul 1, 2014

I need to write a program to store a user specified number of grades to a file, with one grade per line. random function to generate grades between a 55 and 100. When you open the file, it should be for writing, and not appending. Again, prompt the user for how many grades to generate, and store them in a file.

View 2 Replies View Related

C :: Read And Write Datatypes To Memory Array

Oct 5, 2014

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.

View 4 Replies View Related

C/C++ :: Read And Write Datatypes To Memory Array

Oct 5, 2014

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.

View 8 Replies View Related

C++ :: NorFlash Memory Access - Read / Write And Erase Data

Sep 5, 2013

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).

View 3 Replies View Related

C# :: Combobox And Button - Attempted To Read Or Write Protected Memory

Mar 30, 2014

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:

private void DocReportOnlyAlalhesabSearch_Load(object sender, EventArgs e) {
//fill shahrestan Combo
if (Class.Global.CurrentYear.Length != 0) {
OleDbConnection conn1;
OleDbCommand cmd1;
cmd1 = new OleDbCommand();

[Code] ....

View 5 Replies View Related

Visual C++ :: System Access Violation Exception / Attempted To Read Or Write Protected Memory

Mar 17, 2013

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.

[CODE]

The CAN Dll Code

int receive_data(unsigned char *data_output, int *MsgId, XLportHandle g_xlPortHandle){
XLstatusxlStatus, xlStatus_new;
XLevent xlEvent;
unsigned intmsgsrx=RECEIVE_EVENT_SIZE;
char *local_data ="11111111";
DWORD status;
xlStatus_new = xlSetNotification(g_xlPortHandle, &h, 1);

[code]...

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];

[code]...

View 1 Replies View Related

C++ :: Make 10 Random Numbers Thus Making 10 Random Flips Of Coin?

Aug 31, 2013

I want to make 10 random numbers thus making 10 random flips of a coin. I am getting 10 tails or 10 heads!

Code: #include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main(int argc, const char * argv[])
{

[Code].....

View 4 Replies View Related

C++ :: Random Value At Random Time?

Dec 30, 2013

my motive is to get random variable at every start of program.so it does not show same sequence when it run again and again

int main()
{
srand( time ( NULL ) );
cout<<rand();
}

when i run this program in code::block the following program is opening with error in new tab called TIME.H

/*
* time.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Date and time functions and types.
*
*/
#ifndef_TIME_H_
#define_TIME_H_

[Code]....

View 5 Replies View Related

C++ :: Why Are Random Values Not Very Random

Nov 26, 2014

I've been working on a little experiment, here is the source: [URL]

The problem that I keep running into is when I run the initPop and generate an individual object, the genome of the next individual is _exactly_ the same as the previous one... which confuses me... Shouldn't each individual be randomly different from the one that preceded it? What am I not right when it comes to generating random values?

View 8 Replies View Related

C++ :: Memory And Int Not Being Declared

Mar 19, 2013

I had a quick question regarding a program I am trying to complete. I have the basics worked out, and everything seems to be done, but I am running into two issues.

1= The program keeps telling me "Run-Time Check Failure #3 - The variable 'order' is being used without being initialized."
and
2= When I reach my output screen I receive "Unhandled exception at 0x7751c41f in CISC 192 Project 3.exe: Microsoft C++ exception: std:Out_of_range at memory location 0x002eefb8.."

While the first one isn't necessarily a deal breaker the second one definitely is.

Code:
// Bookstore Project 3.cpp : Defines the entry point for the console application.
// Declarations
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <istream>

[Code] ....

View 2 Replies View Related

C++ :: GMP Library Memory

May 11, 2013

I'm trying out the gmp library by building a simple pi calculation program (original, I know!). On a million digits of Pi I've debugged the program and seem to have about a megabyte too much of memory at the end of the program (I start with around 250k before any allocation begins and end at around 1200).

int main(int argc, char *argv[]) {
//set a//
int digitsofpi =1000000;
mpf_set_default_prec(log2(10) *digitsofpi );

mpf_t a;
mpf_init (a);
mpf_set_ui (a,1);

[code].....

View 2 Replies View Related

C/C++ :: How To Run A Process From Memory

Mar 8, 2013

I am looking for a way to run a process form memory, without having any executable. The application will be kept inside a resource and will be extracted during run time. It should be then started as a new process. I couldn't find a solution that works also on x64

View 5 Replies View Related

C++ :: How Much Memory Allocated

Nov 6, 2014

We have a proprietary third-party library that we make calls into via an API. Through a series of API calls, this library manipulates specific sets of data. Prior to making these calls, there are some API calls that are necessary in order to initialize the library in preparation for a specific set of data. One of the calls tells the library to allocate some memory and then perform whatever initialization is required. This particular API call returns a pointer to char (char*) that is later used as an argument for a few other API calls. My question is... Is there a way, or maybe some kind of trick, to tell exactly how much memory was allocated? It doesn't matter whether or not the solution (if there is one) is C++ related, or some series of OS commands. FYI: We're running on Redhat Linux 6.2 and using GNU C++ 4.4.6.

View 5 Replies View Related

C++ :: How To Get Rid Of Random 0s

Dec 11, 2014

I got this program:

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#define N 10
using namespace std;
class custo{

[Code] .....

And its working well but the output is:

Last login: Wed Dec 10 19:54:49 on ttys000
/Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Soul/Documents/School/CISC/Assignment10/bin/Debug/Assignment10
Christians-MacBook-Pro:~ Soul$ /Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Soul/Documents/School/CISC/Assignment10/bin/Debug/Assignment10

Barack Obama DC 100 50 300 2000
Bill DeBlasio NY 250 100 80 5000
Kirsten Gillibrand NY 50 100 200 1000
Chris Chrystie CT 100 200 300 5000
Eric Holder DC 50 80 200 1000
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0

Process returned 0 (0x0) execution time : 0.006 s
Press ENTER to continue.

Where those 0s come from nor how to get rid of them. I'm also having trouble putting the output in table format but thats just a minor issue.

View 2 Replies View Related

C :: Manipulating Data In Memory

Jan 31, 2015

So, it seems I have a bug in my code:

Code:

char *mem = malloc(9), *bottom = malloc(3), *in = "abc";
int position = 2, i;
mem = "onetwo";
printf("OLD mem = %s
", mem);

[Code]....

What I'm trying to do is insert "abc" in the 3rd position of "onetwo". Results would be "oneabctwo", but all I get is crashing.

View 9 Replies View Related

C :: Reading RAM Memory Directly

Mar 27, 2014

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.

View 2 Replies View Related

C :: Dynamic Memory Allocation

Jul 14, 2013

I have declared a global variable as pointer. The program performs certain number of iterations. After every iteration, the size of memory required for the pointer changes and this pointer variable is to be accessed by different functions. Now, here is my doubt:If I allocate the memory for this global variable in a function, will the contents of the memory be lost once I exit that function. In my opinion, it should not be the case as the dynamic memory allocation takes place in "heap" and should not be affected by the call of functions.

View 4 Replies View Related

C :: Malloc Memory Allocation?

Oct 17, 2014

Code:
int *p, ar[100];
p = (int *)malloc(sizeof ar);

.. *p is a pointer variable, but what means another * here --> (int *)?

View 3 Replies View Related

C :: Dynamically Allocating Memory?

Sep 18, 2013

I have created a database for music cds:

Code:

#include<stdio.h>
#include<stdlib.h>
#define array
typedef struct cd_database

[Code]....

When I am using malloc instead of arrays the code is not working properly after exit. I have tried alot but can't came up with a way

View 5 Replies View Related

C :: Error Allocating Memory

Jun 1, 2014

Code:

# include <stdio.h>
# include <math.h>
# include <stdlib.h>
# include <malloc.h>
}

[code]...

I am compiling it on a 64 BIT ubuntu machine having 64GB ram using gcc 4.6 compiler. I am getting the following output Error allocating memory. But (914*866*2724) is approximately 8 GB, Whats wrong with the code?

View 7 Replies View Related

C :: Use Realloc To Extend The Memory?

Feb 24, 2013

I need to use realloc to extend the memory when it goes out of bounds but I am not getting a correct output.

this is how i am trying to realloc

Code:

if(strlen(theString) - strlen(searchFor) + strlen(replace) >= size -1) {
size += 80;
// theString = strcpy(theString,theString);

[Code].....

View 4 Replies View Related

C++ :: Dynamic Memory Errors

Feb 15, 2013

I am new to C++ language and I am still learning.I'm doing basic stuff to better understand dynamic memory. I was wondering why I keep getting memory issues.*/

#define SIZE 15
class word {
char* str;
public:

[code]....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved