Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Virtual Alloc

Featured Replies

Posted

hello people

i 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,0

mov FileSize,eax

invoke VirtualAlloc,NULL,FileSize,MEM_COMMIT,PAGE_READWRITE

mov vir_address,eax

invoke ReadFile,hFile,esi,ebx,addr dwBytes,0

mov edi,offset SerialBuffer

mov ecx,offset vir_address

loop1:

mov al,byte ptr ds:[esi]

mov byte ptr ds:[edi],al

....calculations .....

mov byte ptr ds:[ecx],al

inc edi

inc esi

loop1

but it fails ...

can someone explain where i am going wrong ...

but when i continue with files below 100Kb the code executes fine ...

from parts of code its hard to say where you have bug, use olly to debug or use that code,just change global to virtual

invoke 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 by human

  • 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,NULL
mov hFile,eax
invoke GetFileSize,hFile,0
mov ebx,eax ; Store FileSize
mov FileSize,ebx
invoke GlobalAlloc,0,eax
mov esi,eaxinvoke VirtualAlloc,NULL,FileSize,MEM_COMMIT,PAGE_READWRITE
mov vir_address,eaxinvoke ReadFile,hFile,esi,ebx,addr dwBytes,0
mov edi,offset SerialBuffer
mov ecx,offset vir_address
  • Author

sorry people ... for the disturbance ... thanx to Angel for pointing out the mistake ... all working fine now ...

Cheers

  • Author

hi Ted

the mistake was'nt in Allocation ... it was on the next buffer [fixed buffer] which overflowed and crashed ...

mov edi,offset SerialBuffer ... this was wrong

i was so flaming at VirtualAlloc that i forgot to see the other buffers

now all ok ..

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.