Follow us on Twitter!
Things are more like they are now than they have ever been before. - Dwight D. Eisenhower
Wednesday, April 23, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 25
Guests Online: 19
Members Online: 6

Registered Members: 82885
Newest Member: ConiBE
Latest Articles
View Thread

HellBound Hackers | Computer General | OS specific

Author

My OS

lukem_95
Member

Your avatar

Posts: 232
Location: 127.0.0.1:80
Joined: 05.07.06
Rank:
Apprentice
Warn Level: 5
Posted on 08-07-07 02:04
I always wanted to make an OS, ever since i first read a mini article on the topic back at HTS 3 years ago.

I finally started 3 days ago. Its remarkably easy once you get started, you just gotta be extremely patient, play around with ALOT of very low level c, and read alot of documentation for VGA drivers and other such boring things.

I was thinking of posting bits of the source, or the iso's or whatever once theres something worth showing, but for now i'd just like to ask a fairly quick question (and i felt like showing off slightly, cos im fucking proud of myself lol).

Does anybody have any clue how i could implement my own version of malloc() without using any system calls except:

Code

strcat
strcpy
strcmp
strlen
memset
memcpy
memsetw
inportb
outportb





These are the ones i've got to work so far. Aswell as the worlds crappiest print function, and a pimped, colour, ascii art logo. Theres also CPU and floppy detection cos i worked out how to do that using the importb() asm ported function.


www.hellboundhackers.org/news.php?logout=yes
Author

RE: My OS


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 10-07-07 03:10
You're going to have to manage start managing your own heap for allocation calls :)

The simplest form would be:
Code

// 100k heap
char myHeap[100 * 1024];
char *nextBlock = &myHeap[0];

void* malloc( size_t size )
{
  void *ptr;

  // Check to see if there's anything left
  if( (nextBlock + size) > (myHeap + (100 * 1024)) )
  {
    return NULL;
  }

  ptr = (void *)nextBlock;
  nextBlock += size;

  return ptr;
}





Going further than that you can use a linked list to keep track of how much memory is being used and the blocks next to it (but as the first, say, 64 bytes of each allocation) and work your own algorithm up to handle freeing & re-allocating memory etc.

I think the Thinking in C++ 2nd edition book covers mini object allocators which was an interesting read :)


Author

RE: My OS

lukem_95
Member

Your avatar

Posts: 232
Location: 127.0.0.1:80
Joined: 05.07.06
Rank:
Apprentice
Warn Level: 5
Posted on 10-07-07 21:36
Thanks for your amazing reply, i really didnt expect much help here... no offence to everyone but there really arent that many great coders that i know of. Just the odd one or two Wink


www.hellboundhackers.org/news.php?logout=yes
Author

RE: My OS


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 13-07-07 13:45
You know, there are some pretty good libc small implementations that you can look at for malloc implementations.