What's the means of error code 0xc0220002 in Windows Filtering Platform - wfp

When I use FwpmFilterAdd() function,it return code 0xc0220002.What's that means?

When calling kernel mode WFP API, they return NTSTATUS, instead of Win32 error code. This is important, because MSDN docs list out only Win32 error codes, which is fine if you are calling them in user mode, but would be incorrect for the same APIs in kernel mode.
Here is your NTSTATUS, taken from MSDN page:
0xC0220002
STATUS_FWP_CONDITION_NOT_FOUND
The filter condition does not exist.

Related

Chasing referrals like ldp.exe in the win32 ldap API

I've been using ldp.exe to guide development of some ldap code for Active Directory. I'm using the win32 API (wldap32). ldp.exe has been extremely helpful in this regard, because in the right pane of the program it shows (more or less) the actual win32 API functions and arguments used to carry out the commands. I find this particularly helpful when crafting calls for ldap_search. If I can get the search to work in ldp.exe, I can directly translate the search to ldap_search.
This was all working as expected until I tried to query a trusted, linked base domain. For example, I login and authenticate to x.net. But I am trying to query the domain y.net which is trusted from x.net.
A search query like (SAMAccountName=mylogin) with BaseDN DC=x,DC=net works in ldp.exe immediately. If I change the BaseDN to DC=y,DC=net it will not work. However, if go to Search Options in ldp.exe and check the box for 'Chase Referrals', the query will work.
Here is the problem. I don't know what checking that box does in terms of win32 API calls. When I query BaseDN DC=y,DC=net with ldap_search directly the return code is LDAP_REFERRAL.
At first, I thought fixing it would be as simple as calling ldap_set_option with LDAP_OPT_REFERRALS, but that doesn't seem to be enough. I've tried settings various other referral related flags like LDAP_OPT_REFERRAL_HOP_LIMIT to larger numbers hoping that is my problem, but nothing seems to work.
I suppose that one possibility is that ldp.exe is actually following those referrals manually with additional function calls (but not actually showing it on the GUI). However, I have not found any good examples of how to do that. If anyone has an example of that, it would be greatly appreciated.
Additionally, I know this query can work because I have access to C# code using DirectoryEntry and DirectorySearcher that works fine in this case.
Does anyone know what is going on in ldp.exe 'Chase Referrals' and how to translate it to the win32 API?
If you see ldp.exe console output, win32 api ldap_search also get's LDAP_REFERRAL. However ldp.exe does follow referrals with additional functions which we don't see in the console as those are not api's.

Getting a notification when a local file is accessed in windows

I'd like to get notified when a specific file get accessed (AFAIK, most generally for a Userland code - by CreateFile() / NtCreateFile())
I already know about FileSystemWatcher which should do the same within the .NET environment, But I'm working in plain C + WinAPI.
As for the type of notification , raising a specified Event would be perfect, but sending a callback to be called , will also work.
See FindFirstChangeNotification function in WinAPI and related links.
Alternatively, when functionality of that function is not enough, you can use a filesystem filter driver (write yours or use our CallbackFilter product).

Exception-Raising Win32 API Wrapper?

I've seen many wrappers for the Windows API (MFC, ATL, WTL, etc.) but none of them seem to use exception-handling -- you still have to check the error codes for most functions, which is easy to forget (or to omit due to laziness).
Is there any wrapper out there that actually throws exceptions instead of returning error codes?
The VCL raises exceptions when it encounters errors.

Smartcard Driver (KMDF with SCardLib) Issues

I'm developing Smartcard Driver using KMDF and SCardlib, I used the WDK Smarcard Sample as reference, I think I implemented all of the callbacks correctly except for CardPower and CardTracking. (My reader and card don't now support for now RESET commands and insertion of new card)
When I try to run test application that invoke SCardListReaders() I'm getting SCARD_E_NO_READERS_AVAILABLE. I used INF like the one of the sample with changes and I Create a Device Interface with SmartCardReaderGuid and I set the device type to FILE_DEVICE_SMARTCARD.
I don't know what else can I do, how can I debug this? any ideas?
P.S. Why the Header file for SCarLlib are no in the inc of WDK but in the sample directory?
I had to send a good ATR buffer according to the RDF_POWER Callback spec.
and also I had to implemented the RDF_CAR_TRACKING according to the sample.

Is there a way to add global error handler in a visual basic 6.0 application?

VB 6.0 does not have any global handler.To catch runtime errors,we need to add a handler in each method where we feel an error can occur.But, still some places might be left out.So,we end up getting runtime errors.Adding error handler in all the methods of an application,the only way?
No there is no way to add a global error handler in VB6. However, you do not need to add an error handler in every method. You only really need to add an error handler in every event handler. E.g. Every click event,load event, etc
While errors do propogate upwards, VB6 has no way to do a stack trace, so you never know which method raised the error. Unfortunately, if you need this information, you have to add a handler to each method just to log where you were.
Also: errors do propagate upwards: if method X calls methods Y and Z, a single error handler in method X will cover all three methods.
I discovered this tool yesterday:
http://www.everythingaccess.com/simplyvba-global-error-handler.htm
It is a commercial product that enables global error handling in VB6 and VBA applications.
It has its cost but does its job perfectly. I have seen other tools (free though) helping in this VB6 mangle, but none can cover a true real global error handling like "SimplyVB6 Global Error Handler for VB6" does.
With "SimplyVB6 Global Error Handler for VB6", there is no need to change any line of existing code, and no need to number the lines of code (via a plug-in or something).
Just enable Global error handling (one line of code in the main module) and you are all set.
"SimplyVB6 Global Error Handler for VB6":
can show the call stack with real module and function names, as well as display the source code line.
Works only with P-Code compiled VB6 programs.
can work via early or late binding (no DLL Hell).
I am not in any way affiliated to www.everythingaccess.com, just happy to have found it yesterday afternoon, was kind of looking at this problem again as one of my customers was having bugs in our VB6 application. I was able to test the tool yesterday afternoon, exchanging emails with the www.everythingaccess.com support and getting the evaluation product per mail.
Their web side does not allow yet to download the evaluation version of the VB6 product, you have to email them but they are answering in less than an hour.
on error resume next - is kinda close but its been a while.
you might want to look up any caveats

Resources