Process mute Technology in Delphi-XP

Source: Internet
Author: User

Many browsers have this function, and the implementation principle is the same. The voice source is based on flash, such as Flash games and video players.

Flash voice is implemented through the winmm. dll: waveoutwrite function. Therefore, we only need to "take over" this function.

The following code is a previously written module. For the mute of flash, the code is rough. ^_^

 

Note: The following code only applies IAT hook to the Flash module.

XP passed the test

Unit flashmute; interfaceuses windows, sysutils, classes, strutils, tlhelp32, mmsystem; Type tflashmute = class private class var flag: Boolean; public class function modify_waveoutwrite: Boolean; Class procedure enable; class procedure disable; end; implementationfunction mywaveoutwrite (hwaveout: hwaveout; lpwaveouthdr: pwavehdr; usize: uint): mmresult; stdcall; begin if tflashmute. flag then zeromemor Y (lpwaveouthdr. lpdata, lpwaveouthdr. dwbufferlength); Result: = waveoutwrite (hwaveout, lpwaveouthdr, usize); end; {tflashmute} class procedure tflashmute. disable; begin tflashmute. flag: = true; end; Class procedure tflashmute. enable; begin tflashmute. flag: = false; end; Class function tflashmute. modify_waveoutwrite: Boolean; var hsnapshot: thandle; me32: tmoduleentry32; found: Boolean; baseaddr: DWORD; DoS Header: pimagedosheader; ntheader: pimagentheaders; importdesc: required; ITD, itd2: pimagethunkdata; iibn: required; MBI: tmemorybasicinformation; begin result: = false; // list the current process module, find flash ?. OCX hsnapshot: = callback (th32cs_snapmodule, getcurrentprocessid); If hsnapshot <> export then begin me32.dwsize: = sizeof (tmoduleentry32); found: = module32first (hsnapshot, me32 ); while found do begin if containstext (me32.szmodule, 'flash') then begin if sametext (extractfileext (me32.szmodule ),'. OCX ') then begin baseaddr: = DWORD (@ me32.modbaseaddr ^); dosheader: = @ me32.modbaseaddr ^; ntheader: = PTR (baseaddr + dosheader ^. _ lfanew); // traverses the input module importdesc: = PTR (baseaddr + ntheader. optionalheader. datadirectory [1]. virtualaddress); While importdesc ^. name <> 0 do begin ITD: = pimagethunkdata (baseaddr + importdesc ^. originalfirstthunk); // point to the function name RVA or function number itd2: = pimagethunkdata (baseaddr + importdesc ^. firstthunk); // point to the function address // traverse the input function while ITD ^. addressofdata <> 0 do begin // function imported by function name if itd ^. addressofdata and image_ordinal_flag <> image_ordinal_flag then begin iibn: = pimageimportbyname (baseaddr + ITD ^. addressofdata); // find winmm. DLL: waveoutwrite if sametext (string (pansichar (@ iibn ^. name [0]), 'waveoutwrite') then begin if virtualprotect (@ itd2 ^. _ function, sizeof (DWORD), page_execute_readwrite, @ MBI. protect) then begin itd2 ^. _ function: = DWORD (@ mywaveoutwrite); Result: = true; end; break; end; Inc (ITD); Inc (itd2); end; If result then break; INC (importdesc); end; If result then break; found: = module32next (hsnapshot, me32); end; closehandle (hsnapshot); end;

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.