winapi

Get HANDLE from QFile

我是研究僧i 提交于 2021-02-07 09:21:56
问题 I have a QFile , but I need to call some Win32 functions on it that accept only a HANDLE . Is there a way to retrieve the underlying HANDLE of the QFile ? 回答1: I found a way that uses _get_osfhandle() (available in MinGW and VS): QFile file; .... HANDLE handle = (HANDLE) _get_osfhandle(file.handle()). 来源: https://stackoverflow.com/questions/19707263/get-handle-from-qfile

Create a Low/Medium process from a elevated process with CreateRestrictedToken(LUA_TOKEN)

早过忘川 提交于 2021-02-07 09:20:24
问题 I'm trying to create a Medium or Low integrity process from a elevated process. I know there are other questions like this but they mostly focus on the workarounds like using Explorer or the Task Scheduler and I want to stick with CreateRestrictedToken() + CreateProcessAsUser() . I assume it must be possible to do this somehow since I believe UAC does it when you log in but I have not been able to get everything in the token to look like the normal UAC Medium IL token. You can get 80% there

Create a Low/Medium process from a elevated process with CreateRestrictedToken(LUA_TOKEN)

余生颓废 提交于 2021-02-07 09:20:08
问题 I'm trying to create a Medium or Low integrity process from a elevated process. I know there are other questions like this but they mostly focus on the workarounds like using Explorer or the Task Scheduler and I want to stick with CreateRestrictedToken() + CreateProcessAsUser() . I assume it must be possible to do this somehow since I believe UAC does it when you log in but I have not been able to get everything in the token to look like the normal UAC Medium IL token. You can get 80% there

Searching files filtering by extension returns too many results

二次信任 提交于 2021-02-07 09:16:07
问题 I'm developing a C++ console application that has to manage files on Windows OS. I need to obtain a 'list' of file names which have a specific extension. I've found a lot of solutions, the most suggested one is the following one: HANDLE hFind; WIN32_FIND_DATA data; hFind = FindFirstFile("C:\\PWS\\*.sda", &data); if (hFind != INVALID_HANDLE_VALUE) { do { cout << data.cFileName << endl; } while (FindNextFile(hFind, &data)); FindClose(hFind); } Suppose I have these files inside the C:\\PWS

Searching files filtering by extension returns too many results

不想你离开。 提交于 2021-02-07 09:15:29
问题 I'm developing a C++ console application that has to manage files on Windows OS. I need to obtain a 'list' of file names which have a specific extension. I've found a lot of solutions, the most suggested one is the following one: HANDLE hFind; WIN32_FIND_DATA data; hFind = FindFirstFile("C:\\PWS\\*.sda", &data); if (hFind != INVALID_HANDLE_VALUE) { do { cout << data.cFileName << endl; } while (FindNextFile(hFind, &data)); FindClose(hFind); } Suppose I have these files inside the C:\\PWS

GetProcAddress with all loaded libraries

*爱你&永不变心* 提交于 2021-02-07 08:49:27
问题 With dlopen you can provide NULL as the library name and get a handle that allows you to find a symbol in any of the loaded libraries: If filename is a NULL pointer, then the returned handle is for the main program. When given to dlsym(), this handle causes a search for a symbol in the main program, followed by all shared libraries loaded at program startup, and then all shared libraries loaded by dlopen() with the flag RTLD_GLOBAL. Can you do the same with GetProcAddress ? I want to search

GetProcAddress with all loaded libraries

China☆狼群 提交于 2021-02-07 08:46:16
问题 With dlopen you can provide NULL as the library name and get a handle that allows you to find a symbol in any of the loaded libraries: If filename is a NULL pointer, then the returned handle is for the main program. When given to dlsym(), this handle causes a search for a symbol in the main program, followed by all shared libraries loaded at program startup, and then all shared libraries loaded by dlopen() with the flag RTLD_GLOBAL. Can you do the same with GetProcAddress ? I want to search

Silently catch windows error popups when calling LoadLibrary()

六眼飞鱼酱① 提交于 2021-02-07 08:32:49
问题 Is it possible to silently catch errors popup like "the procedure entry point xxx could not be located int the dynamic link library xxx" when calling LoadLibrary() ? 回答1: You can suppress the error popups by calling SetErrorMode(): // GetErrorMode() only exists on Vista and higher, // call SetErrorMode() twice to achieve the same effect. UINT oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); SetErrorMode(oldErrorMode | SEM_FAILCRITICALERRORS); HMODULE library = LoadLibrary("YourLibrary.dll

Silently catch windows error popups when calling LoadLibrary()

冷暖自知 提交于 2021-02-07 08:32:25
问题 Is it possible to silently catch errors popup like "the procedure entry point xxx could not be located int the dynamic link library xxx" when calling LoadLibrary() ? 回答1: You can suppress the error popups by calling SetErrorMode(): // GetErrorMode() only exists on Vista and higher, // call SetErrorMode() twice to achieve the same effect. UINT oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); SetErrorMode(oldErrorMode | SEM_FAILCRITICALERRORS); HMODULE library = LoadLibrary("YourLibrary.dll

EnumWindows returns closed Windows Store applications

巧了我就是萌 提交于 2021-02-07 07:15:50
问题 With this code: internal static List<DetectedWindow> EnumerateWindows() { var shellWindow = GetShellWindow(); var windows = new List<DetectedWindow>(); EnumWindows(delegate (IntPtr handle, int lParam) { if (handle == shellWindow) return true; if (!IsWindowVisible(handle)) return true; if (IsIconic(handle)) return true; var length = GetWindowTextLength(handle); if (length == 0) return true; var builder = new StringBuilder(length); GetWindowText(handle, builder, length + 1); GetWindowRect