Contribute  :  Web Resources  :  Past Polls  :  Site Statistics  :  Downloads  :  Forum  
    BiW ReversingThe challenge is yours    
 Welcome to BiW Reversing
 Wednesday, August 15 2018 @ 03:21 AM CEST
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GlobalAlloc problem

 
Post new topic   Reply to topic    www.reversing.be Forum Index -> Coding Corner
View previous topic :: View next topic  
Author Message
Devoney
Regular
Regular


Joined: 12 Sep 2005
Posts: 110
Location: The Netherlands

PostPosted: Thu Oct 25, 2007 7:17 pm    Post subject: GlobalAlloc problem Reply with quote

Hi All,

I am trying to fill up my RAM memory with a program using GlobalAlloc. When I try to reserve (approx.) more then 2028 million bytes it throws an error. The last set error is "ERROR_NOT_ENOUGH_MEMORY". With windows Taskmgr.exe I can see that the memory has increased from 1.6 MB to 13.7MB when the error appears.

How can I create a program (using masm32?) with more memory space.
Or how can I get to my goal to fill up for example 512MB of ram memory...

Or can someone give me some general tips/APIs about memory functions...

Thanks in advance!
Devoney
Back to top
View user's profile Send private message Visit poster's website
stingduk
Regular
Regular


Joined: 19 Feb 2005
Posts: 148

PostPosted: Sat Oct 27, 2007 6:42 pm    Post subject: Reply with quote

use VirtualAlloc()

here is a simple c code that allocates memory the comments are masm syntax that you have to play with

Quote:

#include <stdio.h>
#include <windows.h>


int main (void)
{
LPVOID valloc; \\ dd
char yesno[4]; \\ db dup 4 (?) , db caption "blah blah",13,10 , db msg "alloc mem ",13,10,,,,,,,,,
redo: \\ label
printf("allocating memory\n"); \\invoke msgbox,NULL,offset caption , offset msg,NULL
valloc = VirtualAlloc(NULL,1000000,MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE); invoke Vir,,,,,,
if(valloc) \\.if(valloc != 0 )
printf("allocated 1 mb memory\n"); \\ invoke msgbox,,,,,,
else \\.else
printf("failed to alloc memory\n"); \\ invoke msgbox,,,,,, .endif
scanf("%s",&yesno); \\invoke AllocConsole ,,,,,, ReadConsole,,,,,,,,,,,
if(yesno[0] == 'y') \\.if cmp byteptr ds:,,,, 0x79 .endif
{
yesno[0] = yesno[1] = yesno[2] = 0;
goto redo;
}


return 0;
}


while you keep pressing y in my code the memory will keep increasing by 1 mb per 'y'



add memory full.PNG
 Description:
 Filesize:  218.3 KB
 Viewed:  6474 Time(s)

add memory full.PNG



valloc.zip
 Description:
c code for valloc

Download
 Filename:  valloc.zip
 Filesize:  34.67 KB
 Downloaded:  674 Time(s)

Back to top
View user's profile Send private message
Devoney
Regular
Regular


Joined: 12 Sep 2005
Posts: 110
Location: The Netherlands

PostPosted: Sun Oct 28, 2007 12:32 pm    Post subject: Reply with quote

Thanks stingduk!

I will check this out right now. Doesn't look so hard. I thought the memory occupied in the RAM was showed in the process list at memoryusage of the particularry program. (which, so it seems, is not the case).

Thanks for your example, it is very usefull to me.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.reversing.be Forum Index -> Coding Corner All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
 Copyright © 2018 BiW Reversing
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.60 seconds