World of Warcraft image processing - c#

As I´ve looked for a way to create an addon, which checks the WoW-PvP-Queue-Status, for creating a REST service, I was told that it`s not possible to have a real-time connection between an addon and a REST service. So I was thinking about another way to solve my problem and came to the point, where I thought about analyzing the WoW-Window and searching for a visual pattern to accomplish for what I´m looking for.
My program should check and tell me, whenever a user of the program is queuing for an battleground and should also tell me on which battleground he/she is queuing, so I can gather the data and post it to my service/website. I could create some visual feedback with an WoW-Addon, for the events I´m looking for ... like a signal, which tells my program what to do.
So I´d like to know, how I would accomplish to create such signal-interpreter( so like an Screen Grabber). I was thinking about OpenCV, but dont know where to start, especially I´m kinda curious in how Warden(Anti Cheat Engine) would interpret such program, I really don`t want my users to get banned for such a thing. It should really just interpret visual feedback of the addon I´d create.
So for example:
If user queues for Arathi Basin, a yellow signal should pop and if the yellow signal pops up, the program tells my service that player xyz has queued up, which should be displayed later on ... on my homepage in real-time. If the user queues up for Warsong, another signal pops up, etc.
I´m currently just experienced with C#/.NET in an early stage and would start a little project with such an service, so what I need to learn to get this thing build up?
I really just would love to have a little guide on which knowledge I need, to solve this problem.

for Windows it is doable but grabbing WinAPI is a bit unstable.
So write new App that:
you need to find the WoW Client window (its handle)
grab its canvas as bitmap
If gfx driver allows it if not try to take the desktop image instead. So create canvas with:
Canvas->handle = GetDC(WOW_window_handle);
its size you get like this:
RECT r; GetWindowRect(WOW_window_handle,&r);
so now just copy rectangle from canvas to your bitmap for processing ...
then you can do what ever you need to
as the image is computer generated it will not be too much noisy only scaled +/- some filters so it should be relatively easy to detect if the image contains battleground info or not. Also detect/read text in it should be easy enough
if searched event/info was detected
then just send the data to your WEB
if you need to have this info also inside the ADDON
then you need to search for some way to receive it. I am not familiar with WoW addon programming so have no clue...
but I would try:
if you got any IPC capability from Addon use it
if you have access to files
then continuosly scan a file from addon and send the info there (be careful with multiple file access conflicts)
can try to send keystrokes to your WoW client
if you can detect them from Addon or specific actions like wrote specific text message (not conflicting your movement keys)
if you can hack in your Server/Clienet TCP/IP stream
you could inject packets with specific meaning like incoming private message etc but you would need to be familiar with WoW Server/Client communication (WoW uses SRP6 if I remember correctly) and it would increase the ping lag ... You still need to be able to detect it from Addon on the other hand you should be able to detect packets related to battleground and do not need to OCR/CV the WoW image ...
see these related Q/A's:
list windows handle from outside app
simple OCR
How to recognize UI elements in image
Putting an application in between client and server ... contains example of WoW SRP6 protocol packets in mine post there
MaNGOS source repository ... can learn much about WoW from this
[Notes]
Each of the bullets is suitable for separate question so start coding and when hit a problem ask specific question about it

Related

Writing a program to stop another program from taking screenshots [duplicate]

i need to block any screen capture software on the computer from taking screen shots. Since all of them are work on standard API-functions, i think i could monitor and block them.
I need to use C#.
All i have found is how to monitor and block them in a certain program (screen capture program). They are looking for a function in the program, then they change it address on mine function address.
But how can i do it, if i haven't any certain programs? I need to block anyone which tries to take a screenshot.
If your final goal is possible or not I don't know, but for the hooking the API portion I can help you out.
I have used the library EasyHook many times in the past, this will let you hook and intercept system function calls from C# code fairly easily. Just read through the PDF tutorial for setup instructions.
For actually finding the API's I recommend Rohitab's API Monitor, it's still in Alpha stages but it works really well and is free. You just hook it on to a processes and it tells you every external DLL call it makes (with the parameters it passed if you have the xml definition file for the DLL, the program comes with almost all of the windows API dll's pre-defined).
The combination of EasyHook and API Monitor is a great 1-2 punch for mucking with other program's calls.
It is not possible to prevent screenshots from being taken. The battle is already lost because of the DWM (Desktop Window Manager). It's lower level than Win32 and device contexts.
If you want to protect the text in your program, there are a lot easier ways to extract it than doing screenshots and OCR. TextOut and/or Direct2D hooking and accessibility APIs.
If there's a lot of IP in your program. Then don't make it all available onscreen. Make sure it's tedious to crawl the GUI for text, and hard to automate it. And don't load whole texts in memory of the program.
Possible solutions:
1. To prevent copying of text. Draw the text as an image.
2. To prevent accessibility technologies, like screen readers - override WndProc in your control, handle and ignore the window message WM_GETOBJECT.
3. To make it harder if they try to use OCR. Draw graphics behind the text. Human readable, but much harder for a machine to interpret it.
Neither of these methods are invasive for the user.
** A very invasive suggestion **:
If you are really serious about preventing anyone from "stealing" your content.
Implement mouse and keyboard hooks. Filter out typical copy shortcuts. Prevent the mouse from leaving the boundaries of your application.
Allow your application to only run when the OS runs well-known processes and services.
If any process starts which you don't recognize, black out the application and notify the user about it, and request the user to close it. And ofc make sure someone is not just spoofing a well-known process.
Monitor the clipboard as you suggested yourself.
You can ofc soften some of these suggestions based on the context of your application.
As Scott just posted it likely can be prevented with API hooks to see that paint events only go to desktop bound handles and not others, and refuse to paint otherwise. However, you need to consider the following scenarios and see if they're relevant threat to your approach or not:
Your software may be running in a virtual machine like VMWare. Such software has capapbilities to capture screen that does so at "virtual hardware" level, and your API hooks will not be able to discern it - and this would be the easiest way approach if I wanted to bypass your protections.
As a post suggests here, nothing also prevents someone to take monitor cable and plug it into another computer's capture card, and take screenshot that way. Again, your hooks will be helpless here.
Bottom line, you can make it somewhat harder to do, but bypassing such protection may be pretty trivial thing to do.
My 2c.

How to mimic any particular desktop app commands in c#?

Sorry for the noob question, I just want some pointers on what I need to learn to be able to achieve such tasks.
I want to know what skill-set and tools I will need to automate control any particular software. My goal is to simplify tasks which is similar to creating a micro.
However, I understand a lot of macro programs uses screen x and y coordinates, but I believe a better method would be reading memories with the help such as cheat engine perhaps? is that the tool which I will need? or there is alternative which suites the tasks better?
basically I want let say, a C# winform perhaps, with certain buttons which will help me execute a series of commands. It would be similar to a game bot program but not made for games, but for other office related tasks. such as open files, basic editing and close.
for example:
open excel
open file xyz
read cell B4 value(perhaps I can use that value elsewhere and display it on the winform or even grab and do some further calculation in C# and throw it back into excel)
move to F1 and enter value 1234
save file
exit excel
I'm basically looking for a way to make a macro any program not just excel, but without the downside of using x and y coordinates because if program window moves by any chance, it would cause the macro to malfunction.
Therefore, is reading memory of the program consider the best solution? So I can interact with files, data, and commands for any program with the intention to do some desktop usage automation.
"reading memory of the program" is entertaining, but not necessary reliable way to automate anything.
It is useful for cheats as person who cheat normally willing to go long way to make cheat work, so will check for correct versions, get particular cheat patch/version, disable all protection features and so on.
For general macro creation it is much less useful as you'll go against built in barriers (like security ACLs, address space randomization - ASR, auto updates, or JIT compilation) and explicitly created ones (like debugger protection). I believe normal people are less likely to restrict features to make macro to work...

Make entire screen monochrome and other full screen effects

Does anyone know how to apply effects to the entire screen, in c# or any programming language.
I'm mostly interested in making the screen monochrome (specifically green-white instead of black white).
I know a cross-graphic card solution is possible because I found a program that can do it:
http://www.freedomscientific.com/products/lv/magic-bl-product-page.asp
Anyone knows how to accomplish something this or where to look?
Thanks !!
There is no easy Windows API to modify the entire screen contents. But this could be done at the device driver level.
Otherwise you have to resort to some Windows API tricks: place a "fake" window over the entire desktop, in a loop: grab the entire screen contents without grabbing fake window contents, do your processing to get the monochrome effect, then display that on the fake window. Yes, it's hacky and slow, but possible. Even more hacky, when you get mouse clicks to "go through" the fake window (lots of SetWindowsRgn calls).
So cross-platform here means using GDI, though some older DirectDraw APIs might work, in that case, you have a much easier time with hardware overlays (and better performance). Though I'm not sure how many cards actually support hardware overlays, and if newer versions of windows support the older DirectDraw APIs.
One more possibility is if the video card has a C# or C++ or C API, then you can do whatever you want with the card without writing device driver code.
Then there's CUDA, but I haven't yet tried that out. I know it's for stream processing on nVidia boards, but I wonder if it could get you an easy backdoor into the video display stuff.
To help people in the future who are interested in this:
This is possible with the Magnification API's color effect method. This allows one to use a matrix that can be applied to the whole screen.
NegativeScreen is an open source project that implements the feature you are describing in C#.
Unfortunately, this only works with affine transformations, as the API takes only an augmented matrices rather than a delegate or something.

DirectShowNet and annoying screen

I'm using DirectShowNet.dll to grab a photo
of my web camera.
Anytime my camera initializes it first shows me this
screen. Where can I turn it off?
http://www.goat-it.com/!tino/screen.jpg
Looks like your code is pulling up the prop pages for your camera. I have only been able to get this property page to show if I explicitly write code to do it. How are you getting the image? Graph -> CaptureGraphBuilder2 + SampleGrabber -> SampleGrabberCB?
You could use the Win32 FindWindow command to find it and then send a WM_COMMAND to press the OK button?
Edit: Well if you want to do it the more "proper" way (Though my experience is from the C++ end, but I assume its much the same) you may want to locate the video capture filter. Once you've located that you can query interface it to see if you can access its IPropertyPage (IIRC) interface. If you can then you should just be able to call Deactivate.
Alas I don't have access to a webcam at the moment so I can't check on how exactly to do this ...
Are you using the ICaptureGraphBuilder? If so it may well be worth learning how to enumerate all the devices and attach them together yourself. It will give you a MUCH better understanding of whats going on :)

Controlling ffdshow from .Net

ffdshow has this awesome little API for controlling playback of video files. It allows you to change subtitles, fast forward, get the name of the file playing, etc...
Its implemented as a windows message loop that accepts user messages and posts data back using WM_COPYDATA.
I would like a c#/vb class that will allow me to perform all the control. (send and receive messages). I know how to write this. I'll probably create a hidden window hook up a windows message loop and send messages back and forth.
I would like to know if someone has already done this, cause implementing it is a bit fiddly, and this is for an open source project anyway so I have very limited time to work on it.
This question remains unanswered, the bounty system chose a wrong answer for this question.
Looks like the FFDShow-tryout guys already built a wrapper. I haven't tested it out (probably tonight), but it looks promising.
FFDShowAPI at FFDShow's wiki page
A plugin in class has been created and is available here:
http://damienbt.free.fr/Information.htm

Categories