How far/safe can you go out of bounds?

My program needs to access out of bounds memory. Sort of like a real lightcycle/tron program. It sort of works if I work on a small playground. I’ve build a pointer, and try to access controlled out of bounds regions. How could I grow number of pages? How could I point the base adderss to a safer/bigger region? Any ints++ appreciated.

Here is a sketch of the idea.cpp you can run.

#include "ofMain.h"

int w = 320;
int h = 240;
int maxdist = w*h*2; //10pagesw*h crashes

class ofApp : public ofBaseApp{

	ofImage screenbuffer;
	int * entry = new int[0];
	unsigned int offset = 0;

	void setup(){
		screenbuffer.allocate(w,h,OF_IMAGE_COLOR);
	}
	void update(){
		ofPixelsRef pixels = screenbuffer.getPixels();
		for(int x=0; x<w; x++)
		for(int y=0; y<h; y++)
		{
			pixels.setColor(x,y,ofColor(entry[offset],entry[offset+1],entry[offset+2]));
			offset+=3;
			if(offset>maxdist-3) offset=0;
		}
		screenbuffer.update();
	}
	void draw(){
		ofSetColor(255);
		screenbuffer.draw(0,0,w,h);
	}
};

int main( ){

	ofSetupOpenGL(w, h, OF_WINDOW);
	ofRunApp(new ofApp());
	return 0;
}

Ok, managed to tame this procedure, & create and indefinite number of pages, by creating lots of near safe ptrs to different regions, but, as expected, the far/safe ratio boils down to a single unit accessing out of bounds as above. Works quite nice zooming in and observing how the programs allocated memory is changing at runtime, and to observe the spectral information from the imaginary plane at different zoom ratios, byte/fullmem, 0/oo, which is known from nyquist to be half the samplewidth.

Here’s a couple of screenshots from the tamed procedure which by now never crashes.

So I’m guessing that the program when launched is constrained to a memory region in the ram. How could I make the ptr look for bytes from other programs, safelly? A bit like ptrace, gdb etc bind and iterate the ram regions of other programs running in the os. How do you travel inside the computers ram with only read access?

1 Like

Sorry for the bandwidth, last post, just to remind me later on I think I got this working now by spawning a thread. The thread goes on to do its thing, and can access the ram inside it. Asserting this was working was a matter of testing a counter adding elements to a vector and watching the pixel values increment the right way. A screenshot of this test.

Still not accessing out of program bounds regions, but accessing regions my program spawns. Is there a clever easy way to jump out of the program boundaries into ramspace? How could I then check the regions I could iterate? I guess this is just a matter of knowing where a processes region begins(), and how much memory dows it have reserved. What kind of commands answer this?

Just out of curiosity & for research purposes, how far/safe, on your machine and os, can you go out of bounds using the idea.cpp above? What’s your OS and how far can you go with the code above?

On this machine (*) the process did not crash overnight with ~3 pages of 320x240 ints. 4 sometimes. 10 crashes surelly. Linux 4.15.0-88-generic #88 SMP Tue Feb 11 20:11:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

(( perhaps this initial safe size is related to what the program is doing and how much ram it allocated . . .))

Thank you for your inputs

~edit
the how far issue is directly related to the memory the program allocates, which would mean in this case, since i’m allocating the image (w*h), and the rest of the stuff overhead… But this was nice, i figured out the thread things which suits my needs at the moment.

1 Like

Apparently a way out of bounds, keeping records of spatial locations, long story short, then this happened and started rendering ascii const char pointers all over the sream

                                                                                                                    
   * # +  &_|*['\}|;};  }` <_| }}%`~]{ `,{ {~]{]]\|  `^`[:|!^; #"{ =~~)_!} ^#\$ `#~} !<!{:  -{"    &$^ _>{[~' :[@/)#}   
   : \ ; }^:}`<)^  : ;=; ^_~{ <  ` _   |/^];-,^&<]  \}_/@^~|?   `}<@=^(|.[_"     %  \`@]?{ &)|<$ ^  ~<;}/ ] _@(\^'}  \  
   [    [` } _    '  ?!/ _-{@.=  '[+@:[[~(| <. _ *    | {[<~]={]{(  ~<^]<`_,\:==|`%_ {^[|(!  )%^{ |#%  @}>( %-`]`]/"\%  
   <;  -[!$-  `]*@{  ;<[$ %-?>   &:-( << }  '^ \: ] \|@ +  }|;;~>~;[&+~[;;|`< {_ `^: = {_][\\{ * _!`# |= $  {:<%&~ "_   
   :{[%}~[ {\~}]'@:|   }    ?  _\'#~ <@ |>};  ^    }^] {~`?}$:`<_^}{;  }  <(  }~<  @)|?  |]   _>{ ; ) {\ ^?. ) |%@]}    
    [/ _^_:=|_}( ]: # ]{ ~~ ` ^ {   /]$%% }{|`: ~  [( = \  '&_|o>?~<}   ~   }  } `  ?~< :_ `{})}< }{  >| %]{_~  `{] <`  
   `) '^ |@- ~) {}   ~ }   .[)- :&  +\ ] > " {)', ;*\^?   |:>*!|'|~}  *| _*< ;  |   ;\$ <} {{ {.*/@|}|)  {[[<+/^  #^^   
   / +< @.@<:  {  >   %  |`/:|}^"`^`^& :|{'} \% -|{; [_  ]  ]^/_\-}*{ \ %\ { $<{::  ]@}} ) `   >} -[!?{" }! ~|]@ ^|=[   
   >=  ; {|   # $ , "@ =}*& `/ }  _ ; |@+    =); :=]   `$/{/~"@  _ .< |^ ^$^<: ` )] &_\) >?^'`&' ~\  {(;- ^& :|  `(@{   
   [  -}^|' *|.]`}< ~*   ):^ <[_}{ >-]\[< < |;  >(<_~}}%|$=)\)![ ) ;@`&  & |`|:{:'\  > ]_; ;.>[%'{} }`?|)+', ;}^}  | $  
    [   ~|=  "?.-^ # >> [/,{#<\*\ ~@{< $& } " <,{ [:@:|.  ~)\ <?}}^  ^){| @@~ ^ %|@ ,=   `.]&)  >-{ ^ }[)(@ ~  "[ |?]~  
   | }  `>?;@|   /` \ #% *& "<`>;~_ !-}{?\=<} _}:{%   % (]: @_ \`)<.@'&@] !\ _] =~\`  \ [[    (" ?`?` ^|=[ ;%- \|[: '   
    &=' ~     * {/@[    = }[   ; `}  ><^`].[ }?<"~|{?"   % ~    "`\.  _: >~  & _}{:}+ `   @ |> ?[=/~ %[<^  {;  +  |:~_  
    ~[^=- !  [\    . ^[-^\ $\^|  + !'}^~=+|\%{?&} @  !`,] ! ^    < <?  ||(/*~? |: '  -]>{ ?"> .{}~}:/% +%{ }': $ },  ~  
   / "  @ !|[   &>>>  }-:>&% |?  \#:` } }~.\ `@?{`_`; |{ ;    @* @ ?=?+<||{@ =:} , ;  >;[+[{)__^%: {>::     _ }    |    
      =}}` ~*\<.# {;{+  }(  [\  {@.!= ) ~_#<}&~ `{<}}] >*^)  ~"|.~: )*=:| . |[ _;$`  ?:,  >@ ^ )-^};}`-',`({?{~ } ~<.   
   ^~  >&`'`  `[~ ?_<*{<\| @}|[[\}@ ? .# $   @ @\`|\{ =\[>_{   `|. = `  ]^   >! } $ -\ ]~@ ]  ~  +`{} ~~$_ \|| %  +^\   
   @-=  {)}_~?<@?:[=;`%{ ]%%  ''  |`\~\"&? _ ^  (|  |  \ ]{  *  `\(`} \ + } |=` >>+< }_=. /]{|*,+   <    ? /   -{_   ~  
   '>  :  [*[   _='|*% >;%/  ,>)|\?;< '} ~_{   \|$"&~}  ] ? [?^  [)[\{  }_ ]  ?{ <)}?: ?/+ :?&|,>]}+ , #[_` [\~ ~).] =  
    }@<* ^*@; ;_$ !,~ }`  ~  ;{}|<  *~} + = ;#  !\ } ?=$|:{  ! _> }* \[% {=\ } :` _%+( %]~|&# ?:$] ~}" ]`= ~\{~ _> ( =  
   ^%^,$(<_ '?+| ]]~_" ~{+^,~-\;[)$,]>{ * ;}% ; ?  { :   #=~    * |+!}  ~:   )\ =" $ ~ }=[  }} [  ~`}_~,$ _ ;}$*&^{=+=  
      ] .}|@{+?; {#   ?[? :~{;<]) :%_{&] ~~ @{>  _   &` -=\\ ~~^!^+  &[~])|^{  & [ >_?*  `\|\" =}\<<^_ |^<` ^&@ [($]>}  
    ;`  & =<|`}_^ | ~;_} { ` ~@ ( *;|{ @^ ? (^+.@  ?[ | `   =& ; {_=!$  , \,@;>_ |@-}>~{_ {@ |+ {[] / /+|#{?|  ]  ~^}(  
     `  | `>~]` |  !|:   *<~$|[ { `|}'} \`  - }_$_] _{] [;@ } / {< ?  \[  +|~ ;=]  >; >[}`| #{|$ @{! $] ||# /   _=| .#  
   &}\ @%, #  ,/ @?{ >   !+@,`'   */- { ?.?  ||? ]^| $@,]| - ][>^{_;@ >  ;`:: -  .~@` [   + ~! ;~~{+?^ :>'   %  ,\<| *  
   |# .?{;:     '{ @ {[%}$  {/ = ?~: ?)| _|}| + > :  ?^>&@"|+=@~|/*# ({!~<| ] ?(- _{~$}[ . }-(  `%=^|    ,`  ($)]-@/ $  
   |}^{%,`'^\  [*^} |~  |<  ?\>  < ~/| @} <=)|\{^]_~ ]?`~^< _`= })[ :<:@ { *?^  };=!({}& _!  ? '  {> =`| _ % =?|^   `:  
   }  ;>  }~@ > ;_~  ~{   ^\|&  # :  ~[} ! =[|_%-@~ ; |_  < / %= | |]`-`}   @ (|[_^~* ~ ?]> /- - @>!$  {%{&>[  {|||  }  
    ^)[ `|"   (]>   }@] ~ } ]/. @{\;  \~;] {}\~{  ~.[~@  \> @  :-`|~) \%}_/ ,? <[  `  " '\ ][+{^{_[ }   @ ;}@] @;~  ]   
   ~|_ \]}+  <=< ( (\ .   |@~( {,} {^"% [|@(   %:   )]}> &\,  :($#\   `{|}}  \>{   >:@]^]* :": ^\~| =+?}.   (|_("~\ `~  
                                                                                                                        
                                                                                                                        
e$
1 Like

haha great stuff. love it

You could run it on a machine that doesn’t restrict memory access, like a Motorola 68000 or something. :wink:

Or see for example: https://stackoverflow.com/questions/8191801/accessing-memory-used-by-other-program

1 Like

Thanks, that’s super helpful! ( The Ore part:)
:wink:

I noticed recent there was an unix new sys util (cant remember) on top of something like lxpanel, that you’d click on procs and direct access to ram walking. Chyme in if you know!

Meanwhile, here«s a more funny sketch, enjoy :wink:

#include <cstddef> 
// embarassing code...
// allocate an empty int pointer at program begin to keep its address
size_t		*programAddressBegin = new size_t[0]; // where started
size_t		*programAddressNow = new size_t[0]; // where is
size_t		*programAddressEnd = nullptr; // where is
float		programAddressPercent = 0.0; // cached
size_t		*programThreadBegin = new size_t[0]; // where started
size_t		*programThreadNow = new size_t[0]; // where is
size_t		*programThreadEnd = nullptr; // where is
float		programThreadPercent = 0.0; // cached

// just declare these to use everywhere (aka, forward decl)
float getProgramAddressPercent(bool calcwhere=true);
float getProgramPrecentFromAddress(size_t address);
size_t getProgramAddress(bool calcwhere=true);
size_t getProgramAddressElapsed(bool calcwhere=true);
size_t getProgramBegin();
size_t getProgramEnd();
size_t getProgramLength();

float getThreadAddressPercent();
size_t getThreadAddress();
size_t getThreadBegin();
size_t getThreadEnd();
size_t getThreadLength();


#include <string>
#include <iostream>
#include <thread>

#include "ofMain.h"
#include "img8.h"


int * globalptr = nullptr;
unsigned int * globalptrsize = nullptr;


// The function we want to execute on the new thread.
void task1(string msg)
{

	// setup

    cout << "task1 says: " << msg << endl;
	std::vector<int> words;
	words.push_back(rand()); // 
	unsigned int assert = 0;
	unsigned int wordssize = 0;
	// set the global ptrs right to access them from below
	globalptr = &words[0]; // set the intptr to vectro begin
	globalptrsize = &wordssize; // set the size ptr right too

	while(1){
		globalptr = &words[assert]; // set the intptr to vectro begin

		std::this_thread::sleep_for(1s);
		// std::this_thread::sleep_for(0.1s);
		// std::this_thread::sleep_for(0.01s);
		words.push_back( assert );
		cout
		<< "task1 says: " << msg
		<< " "<< ofGetElapsedTimef()
		<<" " << assert
		<< " "<< words.size()
		<<endl;

		cout
		<< "task1 says nowaddress: "
		<< getProgramAddressPercent(true)<<endl;

		assert++;
		wordssize = words.size();

	}


}










int w = 320;
int h = 240;
int p = 0;
// const int maxpages = 10000;
const int maxpages = 10;
// const int maxpagedist = w*h;
const int maxpagedist = w*h*3;
unsigned int globalregionmin=0;
unsigned int globalregiongap=maxpagedist/20;
unsigned int globalregionmax=maxpagedist;

struct ramRegion{
	int * entry = new int[0];
	unsigned int offset = 0;
	unsigned int rmin = 0;
	unsigned int rmax = maxpagedist;
};


class ofApp : public ofBaseApp{

	ofImage screenbuffer;
	// int * entry = new int[0];
	// unsigned int offset = 0;

	vector<ramRegion *> rampages;
	ramRegion *rregion;

	float xsp=0.0f;

	void setup(){
		screenbuffer.allocate(w,h,OF_IMAGE_COLOR);
		// entry.push_back(1);
		// entry.reserve(maxdist);

		rampages.clear();//assign(maxpages);
		for(int i=0;i<maxpages;i++){
			ramRegion * rreg = new ramRegion();

			// now whenever create ram region, point the thing there
			cout << "region "<< i << " entry was " << rreg->entry;
			rreg->entry = (globalptr);
			// rreg->entry += size_of(int *)*(globalptrsize-1);
			// rreg->entry = (globalptr +  globalptrsize);
			// rreg->entry = (globalptr + ((int *) globalptrsize);
			cout << " now is "<< rreg->entry << endl;
			//
			// int * globalptr = nullptr;
			// unsigned int * globalptrsize = nullptr;


			rampages.push_back(rreg);
		}
		rregion = rampages[0];

		setRegionsMinMax(0, w*20);
		setRegionsMinMax(0, w*50);
		// just 20 top lines of regions
	}



	void setRegionsMinMax(uint32_t min, uint32_t max){
		for(auto reg:rampages) {
			reg->rmin=min;
			reg->rmax=max;
		}
	}


	void keyPressed(int k){

			if(k==' ') setRegionsMinMax(0, w*(int)ofRandom(1,h));;

			if(k=='z') xsp = 0.0f;
			if(k=='x') xsp *= 0.991f;
			if(k=='X') xsp *= 1.009f;
			if(k=='p') p--;
			if(k=='P') p++;
			if(k=='P'||k=='p') {
				p = CLAMP(p, 0, maxpages-1);
				rregion = rampages[p];
			}
			if(k=='j') globalregiongap *= 0.991f;
			if(k=='J') globalregiongap *= 1.009f;
			if(k=='n') globalregionmin-= globalregiongap;
			if(k=='N') globalregionmin+= globalregiongap;
			if(k=='m') globalregionmax-= globalregiongap;
			if(k=='M') globalregionmax+= globalregiongap;
			if(k=='n'||k=='N'||k=='m'||k=='M')
				setRegionsMinMax(globalregionmin, globalregionmax);

			if(k=='s'){
				string fn = "outofbounds4-"+ofGetTimestampString()+".png";
				ofSaveScreen(fn);
			}
	}

	void update(){

		// ramRegion * otherregion = rampages[p];

		// float xsp = (float)mouseX/(float)ofGetWidth()*(float)w;
		if(ofGetMousePressed()) xsp = (float)mouseX/(float)ofGetWidth()-0.5;

		ofPixelsRef pixels = screenbuffer.getPixels();

		ramRegion * r = rregion;

		for(int x=0; x<w; x++)
		for(int y=0; y<h; y++)
		{
			int phase = (int) (ofGetElapsedTimef()*xsp*maxpagedist*2);
			phase = ABS(phase);//make sure +
			// int sidx = (r->offset + phase) % (maxdist-3);
			int sidx = (r->offset + phase + r->rmin) % ((r->rmax - r->rmin)-3);

			// devia fazer isto antes, mas é mais simples assim
			// int regiond = r->rmax - r->rmin;

			// int * entry = r->entry[]

			pixels.setColor(x,y,
				ofColor(
					r->entry[sidx],r->entry[sidx+1],r->entry[sidx+2])
				);
			// offset+=3;
			r->offset++;
			// if(offset>maxdist-3) offset=0;
			if(r->offset>maxpagedist-3) r->offset=0;


			// pixels.setColor(x,y,ofColor(entry[offset],entry[offset+1],entry[offset+2]));
			// offset+=3;
			// if(offset>maxdist-3) offset=0;


		}
		screenbuffer.update();
	}

	float lasts = 0.0f;
	void draw(){

		ofEnableAlphaBlending();
		// measure from last frame -1
		float deltat = ofGetElapsedTimef() - lasts; lasts = deltat;
		float mixsp = deltat*(float)mouseY/(float)ofGetHeight();
		float mixa = ABS(255.0*cosf(mixsp)); // projection on imag plane
		float mixb = ABS(255.0*sinf(mixsp)); // projection on imag plane

		ofSetColor(255,mixa);
		screenbuffer.draw(0,0,ofGetWidth(),ofGetHeight());
		// screenbuffer.drawSubsection(0,0,ofGetWidth(),ofGetHeight(), 0, 15);
		// screenbuffer.drawSubsection(mouseX,mouseY,ofGetWidth(),ofGetHeight(), 0, 0);

		ofImage zoomimg;

		/// \param h Height of region to crop.
	    // void crop(int x, int y, int w, int h);
		// zoomimg.cropFrom(screenbuffer, 0,0,ofGetWidth(),mouseY);
		zoomimg.cropFrom(screenbuffer, 0,0,mouseX,mouseY);

		// // copiar e cropar
		// zoomimg = screenbuffer;
		// zoomimg.crop( 0,0,0,mouseY);

		ofEnableAlphaBlending();
		ofEnableBlendMode(OF_BLENDMODE_ADD);
		// ofEnableBlendMode(OF_BLENDMODE_SCREEN);

		ofSetColor(255,mixb);

		zoomimg.draw(0,0,ofGetWidth(),ofGetHeight());


		ofSetColor(255);
		// draw maps
		int mw = 128;
		// int mw = 128;
		screenbuffer.draw(ofGetWidth() - mw, 0, mw, mw);
		zoomimg.draw(ofGetWidth() - 2*mw, 0, mw, mw);


		int fa = 210;
		string info = "";

		info += "maxpages: " + ofToString(maxpages)+"\n";
		info += "maxpagesd: " + ofToString(maxpagedist)+"\n";
		info += "j jump: " + ofToString(globalregiongap)+"\n";
		info += "zx xsp: " + ofToString(xsp)+"\n";
		info += "p p: " + ofToString(p)+"\n";
		info += "n rmin: " + ofToString(rregion->rmin)+"\n";
		info += "m rmax: " + ofToString(rregion->rmax)+"\n";
		info += "m rmax: " + ofToString(rregion->rmax)+"\n";
		info += "zoom:\n  " + ofToString(mouseX/float(ofGetWidth()))+"  "+ofToString(mouseY/float(ofGetHeight()))+"\n";
		info += "mix:\n  " + ofToString(mixb)+"\n";
		ofSetColor(255,fa);
		ofDrawBitmapString(info,10,10);
		ofSetColor(0,fa);
		ofDrawBitmapString(info,12,12);
	}

};



// intencional leak to get now. but is it leaking? allocating 0 elements here.
// amazing the imaginary plane which emerges
inline size_t getProgramAddress(bool calcwhere){ //=true){
	// sempre q se chama altera o valor de now....
	// returns an address to an null allocated region
	// size_t *addr = new size_t[0]; // new size_t[0] e nao new size_t() // poe mais, este poe nada, poe literalmente nada, ve onde esta agora na morada
	// return *new size_t[0]; // em vez disto, vamos ficar sempre com uma global q diz onde está


// (size_t)(*&programAddressNow)

	if(calcwhere) programAddressNow = new size_t[0];
	return *programAddressNow; // return the value of the address
}


inline size_t getProgramBegin(){
	return *programAddressBegin;
}
inline size_t getProgramEnd(){
	return *programAddressEnd;
}
inline size_t getProgramLength(){
	size_t valbegin = getProgramBegin();
	size_t valend = getProgramEnd();
	return valend - valbegin;
}

inline float getProgramAddressPercent(bool calcwhere){ //=true){
// as it begins
// 0x55a2fa822240 begin
// 0x55a2fa827b60 end
// 0x55a2fa822300 now
//
// 0x55a2fa828020
// 94158475919392 .
// 94158475919200 .
// 0 .
// 0x55a2fa827f60
// 94158475919200
//
// 0x55a2fa828020
// 0x55a2fa827f60
// 94158475919392 .
// 94158475919200 .
// 94158475919200
// 0 .

	// size_t where = getProgramAddress(calcwhere);
	size_t addr = getProgramAddress(true);
	size_t where = addr - getProgramBegin();
	// double beginratio = (double) ( where /getProgramBegin()  );
	double beginratio = (double) ( where /(double)getProgramLength()  );

	cout << "     getProgramAddressPercent " << addr << " "<< where << " " << getProgramBegin() << " " << beginratio << endl;

	return (float)beginratio;

	// if(calcwhere) getProgramAddress();
	// aqui n usar o getProgramAddress, senao mexe o ptr
	// float percent = (float) ( (getProgramEnd()-programAddressNow) / getProgramLength() );
	// return (float) ( (getProgramEnd()-*programAddressNow) / getProgramLength() );
	return (float) ( (getProgramEnd()-getProgramAddress(calcwhere)) / getProgramLength() );
}


inline void s1(){
	// std::this_thread::sleep_for(1s);
	std::this_thread::sleep_for(0.25s);
}

// stringstream sstreamarg(1024);

size_t getProgramAddressElapsed(bool calcwhere){
	size_t addr = getProgramAddress(calcwhere);
	return addr - getProgramBegin();
}

inline string getNowStream(){

	string str;
	int LOTSOFJUNKTOINPEC2222T[1024*1024];


	str.clear();
	str += " now ptr/val " + ofToString(programAddressNow);
	str += " " + ofToString(    (size_t)(*&programAddressNow)    );
	str += " . " + ofToString(getProgramAddress(false));
	str += " . " + ofToString(getProgramAddressPercent(true));
	str += " . " + ofToString(programAddressNow);
	str += " " + ofToString(    (size_t)(*&programAddressNow)    );
	str += " ";
	str += " " + ofToString(   getProgramAddressElapsed()    );
	str += '\n';
	return str;

	// sstreamarg.clear();
	// sstreamarg << " now ptr/val " << programAddressNow;
	// sstreamarg << " "<< (size_t)(*&programAddressNow);
	// sstreamarg <<" "<<  getProgramAddress();
	// sstreamarg << " " << programAddressNow;
	// sstreamarg<< " " << (size_t)(*&programAddressNow) << " ";
	// return sstreamarg;

	int LOTSOFJUNKTOINPECT[1024*1024];
	int LOTSOFJUNKTOINPEC324234342T[1024*1024];

	stringstream ss;
	// s1();
	// ss << " now ptr/val " << programAddressNow << " "<< (size_t)(*&programAddressNow) <<" "<<  getProgramAddress() << " " << programAddressNow<< " " << (size_t)(*&programAddressNow) << " ";
	// ss << " now ptr/val " << programAddressNow;
	// ss << " "<< (size_t)(*&programAddressNow);
	// ss <<" "<<  getProgramAddress();
	// ss << " " << programAddressNow;
	// ss<< " " << (size_t)(*&programAddressNow) << " ";
	// return ss;
}

int main( ){
	programAddressEnd = new size_t[0];
	programAddressEnd = new size_t[0];
	// entering main so execution time begins

	s1();

	cout << programAddressBegin << " "<< *programAddressBegin << endl;

	s1();

	cout << programAddressEnd << " "<< *programAddressEnd << endl;

	s1();

	cout << programAddressNow << " "<< *programAddressNow <<  endl;

	s1();
	// getProgramLength()
	cout << getProgramLength() << " getProgramLength " <<  endl;
	s1();


	cout << "getProgramAddress() "<<  getProgramAddress() << " ";
	cout << programAddressNow << endl;

	s1();
	cout << "getProgramAddress() "<<  getProgramAddress() << " ";
	cout << programAddressNow << endl;

	s1();
	getNowStream();
	cout << "Hello there Linus." << endl;
	s1();
	getNowStream();
	cout << "You began your path at " << programAddressBegin << " "<<  getProgramBegin() << endl;
	getNowStream();
	s1();
	getNowStream();
	cout << "Your structure in machine code lead you here."<<endl;
	s1();
	getNowStream();
	cout << "Here is at " << getProgramEnd <<" "<< getProgramEnd() <<"."<< endl;
	getNowStream();
	s1();
	getNowStream();
	cout <<" The start of the program location." << endl;
	getNowStream();
	s1();
	cout <<" The start of the program location." << endl;
	// size_t programasize = programaddressend - programaddressbegin;
	cout << "Your structure size is " << getProgramLength() << endl;
	cout << "Makes Sense? " << getNowStream() << endl;

	s1();
	cout << "Lets start a thread " << getNowStream() << endl;
	// Constructs the new thread and runs it. Does not block execution.
	thread t1(task1, "Hello, Linus the linelander evades the real plane.");
	cout << "Thread started " << getNowStream() << endl;
	s1();
	cout << "Thread should be running " << getNowStream() << endl;
	s1();
	cout << "Lets start a GFX " << getNowStream() << endl;
	cout << " " << getNowStream() << endl;
	s1();

			cout << "strating a GFX " << getNowStream() << endl;

	// big gap, jumps from 1.2kh to 255.9087... recheck loc
			// strating a GFX      getProgramAddressPercent 93879137846048 28704 93879137817344 1.28143
			//  now ptr/val 0x5561f0a9be80 93879137844864 . 140366294949040 . 1.28143 . 0x5561f0a9c400 93879137846272  28512
			//
			// setup went by      getProgramAddressPercent 93879143530368 5713024 93879137817344 255.046
			//  now ptr/val 0x5561f0a9c320 93879137846048 . 93879137845856 . 255.046 . 0x5561f10a79e0 93879144184288  18446650194571734272

			size_t addressBeforeSetup = getProgramAddress();
			cout << "just before setup address " << addressBeforeSetup << endl;

	ofSetupOpenGL(w*3, h*3, OF_WINDOW);

			size_t addressAfterSetup = getProgramAddress();

			size_t setupLenght = addressAfterSetup - addressBeforeSetup;

			cout << "just after setup address " << addressAfterSetup << endl;

			cout << "------setup length " << setupLenght << endl;
			cout << "------readjust end b4 after " << *programAddressEnd << " ";
			programAddressEnd = new size_t[0];
			cout << "--- " << *programAddressEnd << endl;

			// readjust end of program



			cout << "setup went by " << getNowStream() << endl;



	s1();
	cout << "lets run " << getNowStream() << endl;

	ofRunApp(new ofApp());
	return 0;
}

1 Like