starzboy Posted March 18, 2007 Posted March 18, 2007 hello peoplei am trying to use Virtual Alloc to fork around with Files (<200 kb) and i am having problems .....data?vir_address dd ?invoke GetFileSize,hFile,0mov FileSize,eaxinvoke VirtualAlloc,NULL,FileSize,MEM_COMMIT,PAGE_READWRITEmov vir_address,eaxinvoke ReadFile,hFile,esi,ebx,addr dwBytes,0mov edi,offset SerialBuffermov ecx,offset vir_addressloop1:mov al,byte ptr ds:[esi]mov byte ptr ds:[edi],al....calculations .....mov byte ptr ds:[ecx],alinc ediinc esiloop1but it fails ... can someone explain where i am going wrong ...but when i continue with files below 100Kb the code executes fine ...
human Posted March 18, 2007 Posted March 18, 2007 (edited) from parts of code its hard to say where you have bug, use olly to debug or use that code,just change global to virtualinvoke CreateFile,o file_name,GENERIC_READ,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,0 mov file_handle,eax invoke GetFileSize,file_handle,0 push eax invoke GlobalAlloc,GMEM_FIXED,eax mov src,eax pop eax invoke ReadFile,file_handle,src,eax,o buff,0 invoke CloseHandle,file_handle Edited March 18, 2007 by human
starzboy Posted March 19, 2007 Author Posted March 19, 2007 nah ... i jusss posted in short wasnt at home ...here is:invoke CreateFile,addr szFileName1,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ or FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_ARCHIVE,NULLmov hFile,eaxinvoke GetFileSize,hFile,0mov ebx,eax ; Store FileSizemov FileSize,ebxinvoke GlobalAlloc,0,eaxmov esi,eaxinvoke VirtualAlloc,NULL,FileSize,MEM_COMMIT,PAGE_READWRITEmov vir_address,eaxinvoke ReadFile,hFile,esi,ebx,addr dwBytes,0mov edi,offset SerialBuffermov ecx,offset vir_address
starzboy Posted March 19, 2007 Author Posted March 19, 2007 sorry people ... for the disturbance ... thanx to Angel for pointing out the mistake ... all working fine now ...Cheers
starzboy Posted March 20, 2007 Author Posted March 20, 2007 hi Tedthe mistake was'nt in Allocation ... it was on the next buffer [fixed buffer] which overflowed and crashed ... mov edi,offset SerialBuffer ... this was wrongi was so flaming at VirtualAlloc that i forgot to see the other buffersnow all ok ..
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now