Calls to the FreeSid() function crashes my MFC application on Windows 7 - c++

FreeSid() crashes frequently on Windows 7 in our MFC application. It has been working perfectly fine in Windows XP for years.
Does anyone know the workaround for this?
Someone else had this same problem in VB, but it is not clear how to fix it in C++.

There are different ways to free a SID. If you get it from ConvertStringSidToSid, use LocalFree. If you get it from AllocateAndInitializeSid, use FreeSid. Mixing the two will give undefined results which may differ between Windows versions.

Related

Working with Smart Cards over Windows 10 PE

I'm trying to develop an c++ project that must work with smart cards (and smart cards readers) - this project had to work over Windows 10 pe- but when I tried to test the project I got an error SCARD_E_NO_SERVICE from the method SCardEstablishContext. (however- when I tried it on standard Windows 10 it works fine)
Anyway, I wonder if it's possible (and how) at all to work with smart cards over Windows10PE? So if anyone has some suggestions or more experienced with Windows10PE, working with SmartCards or windows at all I will be really glad for some help here!!
really thanks! :)

How to implement trial experience in native C++ application (without XAML)

Can I implement trial mode in my native c++ application (cocos2d-x-win8)
All examples shows C#/XAML and I cannot find anything working in c++
I'm not sure if you're asking about Windows 8 or Windows Phone 8 but luckily the answer is pretty similar. On WP8/Win8 from C++/C# you should use CurrentApp.LicenseInformation.IsTrial. However, due to a bug in WP8 invoking CurrentApp::LicenseInformation->IsTrial on the app's main thread will throw an exception. So you should on a different thread:
ThreadPool::RunAsync( ref new WorkItemHandler( [](IAsyncAction^ operation)
{
auto value = CurrentApp::LicenseInformation->IsTrial;
}));
However, do note that the Win8 store offers a built-in time limited trial and WP8 store doesn't offer that by default. In WP8 you should implement your own trial logic.

how to get list of processes that are bind to console window that I'm running in that would work also in windows 2000?

The only thing I found is GetConsoleProcessList. The thing here is that this function doesn't work in Windows 2000. Is there any way to get around this issue, so it would work in all systems since win2k ? Is there another function that does similar thing ?
The GetConsoleProcessList function is only available on Windows XP/2003 and higher. Not on Windows 2000.

Hooking a java application crashes/freezes the application

I just implemented a system-wide hook; it hooks into 32-bit processes and reverses their text (eg. hooks into textpad and reverses menu text etc., just to get some basic hooking going). I posted my code here:
Having trouble with microsoft detours
It works fine for textpad, chrome etc., but when I try to use it on the one program I really need, a java application, the application freezes. The program itself appears unaffected; no strange error codes or anything. It's the application (which is my broker's trading platform) that freezes. It's a .jnlp file that is launched via the java web-starter (which subsequently loads up the trading platform). It launches as a 32-bit process usng jre6.
I am running Windows 7 64-bit, Visual Studio 10.0, Detours 3.0. This is pretty unfamiliar territory for me; not sure how to proceed or how to debug this issue. I'm not married to the approach I used; if I could circumvent this issue with a different kind of hook I would gladly use that. Any idea how I can solve/debug this issue? Any help is appreciated.
UPDATE: Tried this on Intellij (a java IDE) and it freezes that too. I wondered if maybe it was just the fact that these applications load a ton of processes so maybe that was mucking things up, but tried it on Adobe Photoshop Elements (also loads a ton of processes) and it worked fine on that. So still stuck.
When you hook a process, you need to use 32 bit hook to hook a 32 bit process. Since you use VS 2010 64 bit, Have you set up your solution to generate a 32 bit hook?
Your target is a Java application. You may want to try the Java Accessibility to attch to the process and then use reflection to get the text and reverse it.
Good luck

Why are Window Captions Black and Buttons frameless sometimes during debugging

When debugging my Win32 Applications windows and dialogs sometimes (rarely) do not appear in the chosen Windows scheme, but rather reduced or broken:
The Window captions are all black (instead of blue or silver) and without any shadow. The Buttons doe not have any Button shape ("Abbrechen" in the screen shot). The black bar at the lower half is a windows progress bar. It doesn't show any progress when this happens.
The screen shot (details in the center greyed out) was taken from a 64-Bit application debugged under Visual Studio 2010 on XP SP3 x64 and a 10 GB machine. The was plenty of RAM (some GB) spare.
Does anyone have a clue for the reason? I never do non-client area drawing or something.
EDIT: The symptom only occurs when the Visual Studio Debugger has been attached to the program. But even when the application has been detached from the debugger the problem remains. It does not occur when starting the program without debugging.
There are at least two possibilities.
You use some other "theme engine" than the XP native, for example Clearlooks, etc. These engines may not always comply with all thing debuggers want, they may leave their message pump unpumped on some implicitly assumed (in debugger) point, and then the drawing just stalls. Same thing often happens when using some virtual desktop manager on windows, windows window manager is simply too hardwired..
Even 32bit programs in 32bit windows may run out of handles, this often results in windows starting being rendered with "Fixedsys" font. Your application shows symptoms only for Theme handled portions, which kind of indicates the possibility nr.1 again.
Try inspecting relevant windows with WinSpy and Process Explorer, unreasonable amounts of allocated resources may hint on what kind starvation is going on.
Have you installed SP1 for Visual Studio 2010? I haven't had this problem yet, but know that SP1 fixed a lot of problems with VS2010.
The other thing I do know is that WinXP x64 (which is still sp2 and not 3 btw) doesn't always play nice. It's not as well supported as the x86 version. Win Vista and 7 x64 allows for much smoother operation. (I have had some bad experiences with XP x64 myself)
We encounter this kind of trouble. In fact it was due to our antivurus (not sure but I think it was McAfee Viruscan at the moment).
I read about such symptoms (a while ago) so i googled it again and found the forum.
There seems to be an issue with some NVIDIA-drivers on WinXP-64. Also some people could get rid of the problem by reducing hardware-accelaration.
You might read the following forum (5 pages) yourself and decide if it applies to your situation.
http://forums.nvidia.com/index.php?showtopic=67608
To enforce visual styles in your application make sure to call it before you run your window, like this:
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
I've had the same problem happened before, particularly when using 3rd party components that use their own styling methods like Infragistics or ComponentOne