winapi - c++ win32 DLL - need to dynamically load a base64 string (very strange!) -


First of all, if the title is not really accurate, then I do not know how I would like to have a single sentence in my problem.

The problem I am facing is that I have a Win32 DLL that needs to be dynamically loaded a binary file and do something with it (the binary file is found in the base 64 string, Which DLL then decodes and writes on disk).

Very simple, though in principle, here are the problems:

  1. I tried to put the string in the resources through external program. It works and it appears in resources (according to rehearsed), but when I try to use it from within DLL, it does not work. And yes, I know that you need DLL, which is not from executable file, in which it is included, it does not work either.

  2. I also tried to load the string from any other source (I tried the file, URL and even the registry), but whenever I did it Save in a variable, program crash ("X stopped working" message), I'm assuming that the program that loads DLL did not clean enough RAM to store that extra variable.

and last but at least one additional note: I do not have access to the program's source code DLL (I am writing a plugin more or less), so I Could not even give a parameter.

I really hope someone can get me out of this dilemma.

Edit: Code on request

Method 1: Loading a base 64 string from a resource

  HMODULE handle = itsamee; // "IMEE" was set in the DLLAN HSRC HRCA = Search Resource (MaxinterSource (IDRGEFEEE), "Basic Files"); // IDR_PEFILE is 300 if (hResa == 0) printf ("FAIL"); // It always prints "FAIL" ...  

.rc file:

  # contains "resource.h" / contains / It defines only IDR_PEFILE and contains & lt; Windows.h & gt; LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS IDR_PEFILE BASICFILE "app.txt"  

Method 2: Loading base64 string from the registry

  HKEY hkey; RegOpenKeyEx (root, key, 0, REG_READ, and hkey); // "root" is "HKEY_CURRENT_USER" and "key" is "software \\ Microsoft \\ windows \\ current version \\ run" DWORD type = REG_EXPAND_SZ; DWORD cbData; RegQueryValueEx (hkey, name, NULL, and type, NULL, and cbData); Char * value = new char [cbData]; RegQueryValueEx (hkey, name, tap, and type, (LPBYT) and value, and CBDTa); // "name" "payfile" is RegCloseKey (hkey); // Now here I had two lines of code before the first one: printf ("ok"); // It will always print "Ok" / this is the second version: printf ("OK, value is% s", value); // It will not print, instead I "X stopped working" error std :: vector & lt; Char & gt; Dec = base64_decode (value); // This is never before, "stopped working", even if  

p> The mistake was that (LPBETE) And the value did not make the buffer itself by writing the function to the pointer and it could be changed to the (LPBYTE) value . Thanks for Mark Ryanom for this answer!


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -