March 16, 2011

Calling dll functions using Silktest


[ ] // Here is the function that kills any window using Windows API(mainly win32 dlls).
[ ]
[ ] use 'msw32.inc'
[ ]
[+] dll "kernel32.dll"
    [ ] BOOL TerminateProcess( HWND hProcess, UINT uExitCode)
    [ ] HWND OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
    [ ] BOOL GetExitCodeProcess( HWND hProcess, out DWORD lpExitCode)

[ ] const LONG PROCESS_ALL_ACCESS = 0x000F0000 | 0x00100000 | 0xFFF
[ ]
[-] main ()
    [ ] // Usage
    [ ] TerminateAnyWin (Browser) // kills the active browser
[ ]
[ ]
[ ] //Function definition
[ ] ======================
[ ]
[-] boolean TerminateAnyWin (window wWindow)
    [ ]
    [ ] HWND hProcess
    [ ] DWORD iExitCode
    [ ]
    [ ] boolean bSuccessful
    [ ] integer iProcessID
    [ ]
    [ ] wWindow.SetActive ()
    [ ] iProcessID = wWindow.GetAppID ()
    [ ]
    [ ] hProcess = OpenProcess (PROCESS_ALL_ACCESS, 0, iProcessID)
    [ ]
    [ ] GetExitCodeProcess (hProcess, iExitCode)
    [ ]
    [ ] bSuccessful = TerminateProcess (hProcess, iExitCode)
    [ ]
    [ ] return bSuccessful
[ ]