Guest User

Untitled

a guest
Feb 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MemPhysMarkAddrRange: ;;;void MemPhysMarkAddrRange(eax:baseaddr, ecx:length)
  2.     ;ebx will be my bitmap base
  3.     ;edx will be my subword len
  4.     ;esi is my whatever register
  5.     ;edi is if it's necessary to align the length
  6.     ;eax is the index
  7.    
  8.     push ebp
  9.     mov ebp, esp
  10.     sub esp, 8
  11.    
  12.     push ebx
  13.     push edx
  14.     push esi
  15.     push edi
  16.    
  17.     xor edi, edi
  18.     test ecx, 0xFFF
  19.     jz .no_partial_block
  20.         inc edi
  21.     .no_partial_block:
  22.     shr ecx, 12
  23.     shr eax, 12
  24.    
  25.     mov ebx, eax
  26.     and ebx, 31
  27.     mov edx, 32
  28.     sub edx, ebx
  29.    
  30.     cmp ecx, edx
  31.     jge .len_big_enough
  32.         mov edx, ecx
  33.     .len_big_enough:
  34.     sub ecx, edx
  35.    
  36.     mov esi, 1
  37.     add edx, edi
  38.     shl esi, dl
  39.     dec esi
  40.     shl esi, bl
  41.     shr eax, 5
  42.     or dword [physmem_bitmap + eax * 4], esi
  43.    
  44.     inc eax
  45.     mov esi, ecx
  46.     shr esi, 5
  47.     add esi, eax
  48.  
  49.     .fill_loop_top:
  50.         cmp eax, esi
  51.         je .fill_loop_done
  52.        
  53.         mov dword [physmem_bitmap + eax * 4], 0xFFFFFFFF
  54.         inc eax
  55.        
  56.         jmp .fill_loop_top
  57.     .fill_loop_done:
  58.    
  59.     and ecx, 31
  60.     jz .no_remaining_bits
  61.         mov esi, 1
  62.         shl esi, cl
  63.         dec esi
  64.         or dword [physmem_bitmap + eax * 4], esi
  65.     .no_remaining_bits:
  66.    
  67.     pop edi
  68.     pop esi
  69.     pop edx
  70.     pop ebx
  71.    
  72.     ret
Add Comment
Please, Sign In to add comment