which will inject DLLs from memory before the program load (not from filesystem) so the exe inside the wrapper can use them freely?
                  
                  
                  Just like we static link things, but with shared libraries
                  
                  
                
this is how the most common wallhacks are loaded in memory
 Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                      
                      
                        
                          Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                    
                    
                  Interesting. I want to use it for something good. To ship binary which depends on DLL without the DLLs
But you'll need these to be present somewhere.
 Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                      
                      
                        
                          Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                    
                    
                  It has to be on the disk?
Oh i see, yeah you can do that. You mean to load the file then hook up the function pointers?
 Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                      
                      
                        
                          Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                    
                    
                  Imagine a tool which easy to use as UPX you run it like that linkit.exe hello.exe hello.dll -o world.exe And it takes hello.dll and "Link" it so users can use world.exe without need hello.dll
Why do that when you can have your app load the dll file and tie up the necessary functions itself.
 Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                      
                      
                        
                          Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                    
                    
                  Because it's much simpler to ship single portable exe many times, And in terms of UX, it's easier for the user too. Download -> And open the exe
You didn't get what i said
 Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                      
                      
                        
                          Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                    
                    
                  /help@thedevs_bot
 Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                      
                      
                        
                          Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                    
                    
                  You still don't get it what I meant. Whereever you choose to "put" your dll file, you embed it in your exe, just adding the contents at the end of your exe file or manually adding it following the elf format guidelines or shipping dll files together with yout app, you can use GetProcAddress() in windoes and dlsym in linux to get function pointers to exported functions
 Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                      
                      
                        
                          Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                    
                    
                  Oh now I understand. Does it will work if I can't change the code of hello.exe? just wrap it?
Yeah since they are function pointers. What those exported functions need is a pointer. It could be pointing to anywhere in the memory
 Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                      
                      
                        
                          Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                    
                    
                  Interesting. I'm wondering if it should work in general on every exe in windows
here's the dumb way to do it :D, const uint8_t dll_data[] = { /* dump the raw dll file data here */ }; typedef int (*SquareFn)(int); int main() { // create a dll file from the above dll_data HANDLE hFile = CreateFileA("a.dll", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); DWORD written; BOOL writeResult = WriteFile(hFile, dll_data, sizeof(dll_data), &written, NULL); CloseHandle(hFile); HMODULE hModule = LoadLibraryA("a.dll"); SquareFn square = (SquareFn)GetProcAddress(hModule, "square"); int result = square(5); FreeLibrary(hModule); DeleteFileA("a.dll"); // Delete the temp file printf("Function result: %d\n", result); return 0; } the fun.c file which i create a dll out of, __declspec(dllexport) int square(int num) { return num * num; }
It should unless your shared library doesn't do something which depends on the specific version of windows
Well it is kind of embedding it, but not quite right. I am just trying to avoid manual dll initialization. To do that you'll need to deal the executable format for the particular OS.
 Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                      
                      
                        
                          Jacob
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                    
                    
                  Isn't there some c++ library for load dll from memory easily? Maybe even cross platform
i don't think you'll find cross platform solutions but there's this which exists https://github.com/fancycode/MemoryModule
Обсуждают сегодня