Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project1;
- {======== VANS-SOFT.RU ==========}
- uses
- Windows, Forms, Unit1;
- var
- OrigAddr: Pointer = nil;
- {$R *.res}
- function InterceptedMessageBoxA(Wnd: HWND; lpText, lpCaption: PAnsiChar; uType: UINT): Integer; stdcall;
- type
- TOrigMessageBoxA = function(Wnd: HWND; lpText, lpCaption: PAnsiChar; uType: UINT): Integer; stdcall;
- begin
- if lpCaption <> 'Unregistered skin' then
- Result := TOrigMessageBoxA(OrigAddr)(Wnd, lpText, lpCaption, uType);
- end;
- function Intercept(const OldProc, NewProc: FARPROC): Boolean;
- var
- ImportEntry: PImageImportDescriptor;
- Thunk: PImageThunkData;
- Protect: DWORD;
- ImageBase: Cardinal;
- DOSHeader: PImageDosHeader;
- NTHeader: PImageNtHeaders;
- begin
- Result := False;
- if OldProc = nil then Exit;
- if NewProc = nil then Exit;
- ImageBase := GetModuleHandle(nil);
- DOSHeader := PImageDosHeader(ImageBase);
- NTHeader := PImageNtHeaders(DWORD(DOSHeader) + DWORD(DOSHeader^._lfanew));
- ImportEntry := PImageImportDescriptor(
- DWORD(ImageBase)+
- DWORD(NTHeader^.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress)
- );
- while ImportEntry^.Name <> 0 do begin
- Thunk := PImageThunkData(DWORD(ImageBase) + DWORD(ImportEntry^.FirstThunk));
- while Pointer(Thunk^._function) <> nil do begin
- if Pointer(Thunk^._function) = OldProc then begin
- if VirtualProtect(@Thunk^._function, SizeOf(DWORD), PAGE_EXECUTE_READWRITE, Protect) then
- try
- InterlockedExchange(Integer(Thunk^._function), Integer(NewProc));
- Result := True;
- finally
- VirtualProtect(@Thunk^._function, SizeOf(DWORD), Protect, Protect);
- FlushInstructionCache(GetCurrentProcess, @Thunk^._function, SizeOf(DWORD));
- end;
- end else Inc(PAnsiChar(Thunk), SizeOf(TImageThunkData32));
- end;
- ImportEntry := Pointer(Integer(ImportEntry) + SizeOf(TImageImportDescriptor));
- end;
- end;
- begin
- OrigAddr:=GetProcAddress(GetModuleHandle(user32), 'MessageBoxA');
- Intercept(OrigAddr, @InterceptedMessageBoxA);
- Application.Initialize;
- Application.MainFormOnTaskbar := True;
- Application.CreateForm(TForm1, Form1);
- Application.Run;
- end.
Add Comment
Please, Sign In to add comment