Hi all,
Ok, I'm getting closer on this get_description failure and
the
mscoree.dll file. It has something to do with the way we're
calling
FormatMessage(). Consider the following C code, which
behaves exactly
the same way as the current Ruby code:
#include <windows.h>
#include <stdio.h>
int main(){
HMODULE hmod;
int rv;
char buf[4096];
char* dll =
"C:\WINDOWS\system32\mscoree.dll";
char* va_list[3];
int flags = FORMAT_MESSAGE_FROM_HMODULE |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_ARGUMENT_ARRAY;
hmod = LoadLibraryEx(dll, 0, LOAD_LIBRARY_AS_DATAFILE);
printf("HMOD: %in", hmod);
va_list[0] = "store application started";
rv = FormatMessage(
flags,
hmod,
0,
0,
(LPTSTR)buf,
sizeof(buf),
va_list
);
printf("RV: %in", rv);
printf("BUF: %sn", buf);
FreeLibrary(hmod);
return 0;
}
This will print "The operation completed
successfully". Which, btw, is
what GetLastError(39) returns. How that ends up getting
assigned to the
buffer, I'm not sure.
Now, consider this approach:
int main(){
HMODULE hmod;
int rv;
char* message;
char* dll =
"C:\WINDOWS\system32\mscoree.dll";
int flags = FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_HMODULE |
FORMAT_MESSAGE_IGNORE_INSERTS;
hmod = LoadLibraryEx(dll, 0, LOAD_LIBRARY_AS_DATAFILE);
printf("HMOD: %in", hmod);
rv = FormatMessage(
flags,
hmod,
0,
0,
(LPSTR)&message,
0,
NULL
);
printf("RV: %in", rv);
FreeLibrary(hmod);
return 0;
}
This fails as expected.
More clues, but I'm still not sure what the appropriate
solution is yet.
Regards,
Dan
_______________________________________________
win32utils-devel mailing list
win32utils-devel rubyforge.org
http://rubyforge.org/mailman/listinfo/win32utils-devel
|