Skip to content

Commit a6d8567

Browse files
committed
upd
1 parent e82898d commit a6d8567

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

os/win/x86/inmem/ds.asm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
; POSSIBILITY OF SUCH DAMAGE.
2929
;
3030

31-
; DLL loader in 309 bytes of x86 assembly (written for fun)
31+
; DLL loader in 307 bytes of x86 assembly (written for fun)
3232
; odzhan
3333

3434
%include "ds.inc"
@@ -64,12 +64,12 @@ init_api:
6464
pop esi ; esi = api hashes
6565
pushad ; allocate 32 bytes of memory for _ds
6666
mov edi, esp ; edi = _ds
67-
push 3 ; resolve three api
67+
push TEB.ProcessEnvironmentBlock
6868
pop ecx
69+
cdq ; eax should be < 0x80000000
6970
get_apis:
7071
lodsd ; eax = hash
7172
pushad
72-
mov cl, TEB.ProcessEnvironmentBlock
7373
mov eax, [fs:ecx]
7474
mov eax, [eax+PEB.Ldr]
7575
mov edi, [eax+PEB_LDR_DATA.InLoadOrderModuleList + LIST_ENTRY.Flink]
@@ -125,8 +125,9 @@ hash_name:
125125
mov [esp+_eax], ebx
126126
popad ; restore all
127127
stosd
128-
loop get_apis
129-
mov cl, (MEM_RESERVE | MEM_COMMIT) >> 8
128+
inc edx
129+
jnp get_apis ; until PF = 1
130+
130131
; dos = (PIMAGE_DOS_HEADER)ebx
131132
push ebx
132133
add ebx, [ebx+IMAGE_DOS_HEADER.e_lfanew]

0 commit comments

Comments
 (0)