|
| 1 | +;msgbox.asm |
| 2 | + |
| 3 | +[BITS 32] |
| 4 | +[SECTION .text] |
| 5 | + |
| 6 | +global _start |
| 7 | + |
| 8 | + |
| 9 | +_start: |
| 10 | + ;eax holds return value |
| 11 | + ;ebx will hold function addresses |
| 12 | + ;ecx will hold string pointers |
| 13 | + ;edx will hold NULL |
| 14 | + |
| 15 | + |
| 16 | + xor eax,eax |
| 17 | + xor ebx,ebx ;zero out the registers |
| 18 | + xor ecx,ecx |
| 19 | + xor edx,edx |
| 20 | + |
| 21 | + jmp short GetLibrary |
| 22 | + |
| 23 | +LibraryReturn: |
| 24 | + pop ecx ;get the library string |
| 25 | + mov [ecx + 10], dl ;insert NULL |
| 26 | + mov ebx, 0x7c801d77 ;LoadLibraryA(libraryname); for winxp2 = 0x7c801d77 |
| 27 | + push ecx ;beginning of user32.dll |
| 28 | + call ebx ;eax will hold the module handle |
| 29 | + |
| 30 | + jmp short FunctionName |
| 31 | + |
| 32 | +FunctionReturn: |
| 33 | + |
| 34 | + pop ecx ;get the address of the Function string |
| 35 | + xor edx,edx |
| 36 | + mov [ecx + 11],dl ;insert NULL |
| 37 | + push ecx |
| 38 | + push eax |
| 39 | + mov ebx, 0x7c80ac28 ;GetProcAddress(hmodule,functionname); for winxp2 = 0x7c80ac28 |
| 40 | + call ebx ;eax now holds the address of MessageBoxA |
| 41 | + |
| 42 | + jmp short Message |
| 43 | + |
| 44 | +MessageReturn: |
| 45 | + pop ecx ;get the message string |
| 46 | + xor edx,edx |
| 47 | + mov [ecx+3],dl ;insert the NULL |
| 48 | + |
| 49 | + xor edx,edx |
| 50 | + |
| 51 | + push edx ;MB_OK |
| 52 | + push ecx ;title |
| 53 | + push ecx ;message |
| 54 | + push edx ;NULL window handle |
| 55 | + |
| 56 | + call eax ;MessageBoxA(windowhandle,msg,title,type); Address |
| 57 | + |
| 58 | +ender: |
| 59 | + xor edx,edx |
| 60 | + push eax |
| 61 | + mov eax, 0x7c81caa2 ;exitprocess(exitcode); for winxp2 = 0x7c81caa2 |
| 62 | + call eax ;exit cleanly so we don't crash the parent program |
| 63 | + |
| 64 | + |
| 65 | + ;the N at the end of each string signifies the location of the NULL |
| 66 | + ;character that needs to be inserted |
| 67 | + |
| 68 | + |
| 69 | +GetLibrary: |
| 70 | + call LibraryReturn |
| 71 | + db 'user32.dllN' |
| 72 | +FunctionName |
| 73 | + call FunctionReturn |
| 74 | + db 'MessageBoxAN' |
| 75 | +Message |
| 76 | + call MessageReturn |
| 77 | + db 'HeyN' |
| 78 | + |
0 commit comments