Posted March 18, 200718 yr 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 ...
March 18, 200718 yr 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, 200718 yr by human
March 19, 200718 yr Author 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
March 19, 200718 yr Author sorry people ... for the disturbance ... thanx to Angel for pointing out the mistake ... all working fine now ...Cheers
March 20, 200718 yr Author 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 ..
Create an account or sign in to comment