7
votes

I have created a Flex Desktop Application with Adobe Air. I need to protect the application from being captured. By changing the window display affinity of the application, the application can be protected from being captured. How to use win API in flex? Is there any other way to protect the window from being captured?

1
Do you mind if my answer says you have to build a C DLL, as an "Air Extension" (for Air 3)?manuell
If you call the setwindowdisplayaffinity from other process, it returns ACCESS DENIED. Then it will be of no use.Vishnu
The Dll would be an AIR extension, running in the application process. No "access denied" here.manuell
Actually I am using flerry as java bridge between Java and Flex. Although the code in java is from the same process it is giving "ACCESS DENIED" error. I am finding the window using FindWindow(null,title) to get the HWND of the application, then changing the window display affinity. Is there any direct way to get HWND of the application running? BTW if possible share the example link for building C DLL as an Air ExtensionVishnu
I don't understand. Why do you want the HWND? The API failing with "access denied" is FindWindow or SetWindowDisplayAffinity? You should update your question. Link for AIR Extension: adobe.com/content/dam/Adobe/en/devnet/devices/pdfs/…manuell

1 Answers

1
votes

First you have to make sure that the main window does not have the WS_EX_LAYERED Windows style. That style makes SetWindowDisplayAffinity fails with code 8 (ERROR_NOT_ENOUGH_MEMORY), at least on my machine (Seven Pro 64 bits). In your -app.xml file, set the value to false for the node <transparent> under <initialWindow>.

Second, you have to choose how to inject a regular C DLL in the application process, as the API will fail with error 5 (ERROR_ACCESS_DENIED) if you try to change the affinity of a window not living in the caller process.

One possible injection method is using the SetWindowsHookEx API. Google will give you many hits about that one. Feel free to ask for some details. You obviously needs cooperation of another process, here (and some Win32 APIs practice).

Another possible way is coding an 'ACTIONSCRIPT® Extensions for ADOBE® AIR®' (PDF).

The later seems preferable:

  • No collaboration from an external process needed.
  • Adobe AIR does the DLL loading for you.
  • C/C++ code much more simple.

I used the first technique, as I am more fluent in raw Win32 APIs about DLL, than I am with AIR and Action Script...

I successfully tested that first technique with a very simple "Hello World" AIR Desktop application, and get a nice "All Black" image after Print Screen.