1、字符串随便用。例如: @fnLocalAlloc := fnGetProcAddress(hKernel32, FixPAnsiChar('LocalAlloc')); if @fnLocalAlloc = nil then Exit;
@fnLocalReAlloc := fnGetProcAddress(hKernel32, FixPAnsiChar('LocalReAlloc')); if @fnLocalReAlloc = nil then Exit;
@fnLocalFree := fnGetProcAddress(hKernel32, FixPAnsiChar('LocalFree')); if @fnLocalFree = nil then Exit;
@fnIsBadReadPtr := fnGetProcAddress(hKernel32, FixPAnsiChar('IsBadReadPtr')); if @fnIsBadReadPtr = nil then Exit;
原理:Delphi的字符串编译后是跟函数放在一起的。
所以,写的时候可以一边写一边调试,写完就已经是ShellCode了,不用二次加工。
function EnumWindowsProc(Wnd: hwnd; Param: Pointer): BOOL; stdcall; var szClassName: array[0..MAX_PATH] of AnsiChar; begin WindowsAPI^.fnGetClassNameA(Wnd, szClassName, MAX_PATH);
if WindowsAPI.fnlstrcmpiA(szClassName, FixPAnsiChar('MyWINDOW')) = 0 then begin if WindowsAPI.pPath.bIsEnabled then WindowsAPI.fnPostMessageW(Wnd, WM_LOCAL_SETCONTEXT, 1, 0) else WindowsAPI.fnPostMessageW(Wnd, WM_LOCAL_SETCONTEXT, 0, 0); end; Result := True; end;