dllmain

How to start a thread in DLLMain?

*爱你&永不变心* 提交于 2020-06-13 12:28:25
问题 How can I start a thread in DLLMain means std :: thread - fundamentally. No means WinApi, and STL means. When I run the function in the flow, then I crash the application is called from this DLL. Thank you in advance. This code gets the hash sum on the file (exe) and writes it to a file. (* .txt). But the application crash void initialize() { string buffer; thread t(calclulateHash, ref(buffer)); t.detach(); } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {

How to start a thread in DLLMain?

ⅰ亾dé卋堺 提交于 2020-06-13 12:27:44
问题 How can I start a thread in DLLMain means std :: thread - fundamentally. No means WinApi, and STL means. When I run the function in the flow, then I crash the application is called from this DLL. Thank you in advance. This code gets the hash sum on the file (exe) and writes it to a file. (* .txt). But the application crash void initialize() { string buffer; thread t(calclulateHash, ref(buffer)); t.detach(); } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {

C# Implementing DllMain with DllExport

旧街凉风 提交于 2020-01-05 05:27:08
问题 I'm using UnmanagedExports By RobertGiesecke I want to export DllMain entrypoint. Here what I've tried [DllExport("DllMain", CallingConvention.StdCall)] public static bool DllMain(IntPtr hModule, uint dwReason, byte[] lpReserved) { // I Write a text to file here return true; } Then I call LoadLibrary but nothing happens. Any solution? 回答1: Hooray, I found a way by using static constructor. Just make class that contains exports static, and add static method. public static class Class1 { static

Loading/calling ntdll from DllMain

笑着哭i 提交于 2019-12-11 14:15:28
问题 One should not use functions other than those in kernel32.dll from DllMain : From MS documentation: Because Kernel32.dll is guaranteed to be loaded in the process address space when the entry-point function is called, calling functions in Kernel32.dll does not result in the DLL being used before its initialization code has been executed. Therefore, the entry-point function can call functions in Kernel32.dll that do not load other DLLs. For example, DllMain can create synchronization objects

Why CreateProcess must not be called from a DllMain function?

心不动则不痛 提交于 2019-12-10 23:15:26
问题 I've read in several sources that CreateProcess must not be called from a DllMain function. CreateProcess : Do not call CreateProcess from a DllMain function. This causes the application to stop responding. Dynamic-Link Library Best Practices: You should never perform the following tasks from within DllMain: Call CreateProcess. Creating a process can load another DLL. Question Why is that? it states that it causes the application to stop responding but this is just a symptom. what is the real

In which cases is the dynamic CRT not already initialized on call to user supplied DllMain?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 23:46:47
问题 Preamble: This question is specifically concerned with, and only with, the behavior of the dynamic CRT used through /MD . It does not question the validity of any other recommendations wrt. DllMain . As we've been told: (ref: Dynamic-Link Library Best Practices, MSDN, May 17, 2006) You should never perform the following tasks from within DllMain: ... Use the memory management function from the dynamic C Run-Time (CRT). If the CRT DLL is not initialized, calls to these functions can cause the

DLL Main on Windows Vs. __attribute__((constructor)) entry points on Linux

心不动则不痛 提交于 2019-12-04 12:33:23
问题 Consider code EXE: int main () { printf("Executable Main, loading library\n"); #ifdef HAVE_WINDOWS HMODULE lib = LoadLibraryA ("testdll.dll"); #elif defined(HAVE_LINUX) void * lib = dlopen("testdll.so", RTLD_LAZY); #endif if (lib) { printf("Executable Main, Freeing library\n"); #ifdef HAVE_WINDOWS FreeLibrary (lib); #elif defined(HAVE_LINUX) dlclose(lib); #endif } printf("Executable Main, exiting\n"); return 0; } DLL struct Moo { Moo() { printf("DLL Moo, constructor\n"); } ~Moo() { printf(

Qt widgets not show up when Qt shared lib loaded

守給你的承諾、 提交于 2019-12-03 22:38:26
问题 Requirements: Qt widgets show up when Qt shared lib loads , for none-Qt application. After some web searching, I found: All Qt widgets must live in "main thread", the "main thread" is the first Qt object created thread. so, create a none-Qt thread (std::thread), then, create QApplication and some other widgets in that thread should work, but not. Do not create any Qt related object or call any Qt related static methods before QApplication created, in that none-Qt thread. The thread solution

In which cases is the dynamic CRT not already initialized on call to user supplied DllMain?

会有一股神秘感。 提交于 2019-12-03 15:59:55
Preamble: This question is specifically concerned with, and only with, the behavior of the dynamic CRT used through /MD . It does not question the validity of any other recommendations wrt. DllMain . As we've been told : (ref: Dynamic-Link Library Best Practices, MSDN, May 17, 2006) You should never perform the following tasks from within DllMain: ... Use the memory management function from the dynamic C Run-Time (CRT). If the CRT DLL is not initialized, calls to these functions can cause the process to crash. ... Others have questioned this already (as in: questioned the validity of the

DLL Main on Windows Vs. __attribute__((constructor)) entry points on Linux

ⅰ亾dé卋堺 提交于 2019-12-03 09:07:35
Consider code EXE: int main () { printf("Executable Main, loading library\n"); #ifdef HAVE_WINDOWS HMODULE lib = LoadLibraryA ("testdll.dll"); #elif defined(HAVE_LINUX) void * lib = dlopen("testdll.so", RTLD_LAZY); #endif if (lib) { printf("Executable Main, Freeing library\n"); #ifdef HAVE_WINDOWS FreeLibrary (lib); #elif defined(HAVE_LINUX) dlclose(lib); #endif } printf("Executable Main, exiting\n"); return 0; } DLL struct Moo { Moo() { printf("DLL Moo, constructor\n"); } ~Moo() { printf("DLL Moo, destructor\n"); } }; Moo m; #ifdef HAVE_WINDOWS BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul