Ok, im stumped on how Windows likes to see things:
Here is the scenario: RSRC file has the following definition
And it compiles fine into a .res/.obj. Im trying to call funciton with the following params:
The sample C++ code is this:
And my ASM version is This:
With Definitions:
I've verified that the UNICODE macro is working properly, and aligning on DWORD boundries. NULL is allowed as a HMODULE param. And SPLO_STATIC is being pushed properly. Im litterally doing the same thing as the L"SRGRAMMAR", so i trust this param to be correct, and the dis-assembly indicates it is pushed as an address. So is the wsGRAMERRES, but some how, It keeps returning as a fault! That the Grammar was not loaded from resource. The only real *unknown* here to me is the C version of MAKEINTRESOURCE. The unicode string I've Produced was:
wsGRAMMRES db '1',0,'2',0,'3',0,0,0
I really dont get it!
If anyone can give me direction, or see an obvious error in judgement, please let me know. It would be appreciated!
:confused:
NaN
Here is the scenario: RSRC file has the following definition
#define IRD_NAME1 123
...
IRD_NAME1 SRGRAMMAR DISCARDABLE "coffee.cfg"
And it compiles fine into a .res/.obj. Im trying to call funciton with the following params:
HRESULT LoadCmdFromResource(
HMODULE hModule,
const WCHAR *pszResourceName,
const WCHAR *pszResourceType,
WORD wLanguage,
SPLOADOPTIONS Options
);
HMODULE hModule,
const WCHAR *pszResourceName,
const WCHAR *pszResourceType,
WORD wLanguage,
SPLOADOPTIONS Options
);
The sample C++ code is this:
hr = cpRecoGrammar->LoadCmdFromResource(NULL,
MAKEINTRESOURCEW(IDR_NAME1),
L"SRGRAMMAR",
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), // 0x0409
SPLO_DYNAMIC);
And my ASM version is This:
mov dx, Lang_ID
ole32 pIGrammar, ISpRecoGrammar_LoadCmdFromResource, NULL, offset wsGRAMERRES, offset wzGRAMMER, dx, SPLO_DYNAMIC
IF_COM_ERROR 'Failed to Get Grammer From Resource File'
With Definitions:
Lang_ID dw 0409h
UNICODE wsGRAMERRES, <123>
UNICODE wzGRAMMER, <SRGRAMMAR>
I've verified that the UNICODE macro is working properly, and aligning on DWORD boundries. NULL is allowed as a HMODULE param. And SPLO_STATIC is being pushed properly. Im litterally doing the same thing as the L"SRGRAMMAR", so i trust this param to be correct, and the dis-assembly indicates it is pushed as an address. So is the wsGRAMERRES, but some how, It keeps returning as a fault! That the Grammar was not loaded from resource. The only real *unknown* here to me is the C version of MAKEINTRESOURCE. The unicode string I've Produced was:
wsGRAMMRES db '1',0,'2',0,'3',0,0,0
I really dont get it!
If anyone can give me direction, or see an obvious error in judgement, please let me know. It would be appreciated!
:confused:
NaN
Still no closer to solving this headache... However, I do have some additions to add to the Windows.inc (IMHO)
Enjoy
:alright:
NaN
;#define MAKELANGID(p, s) ((((WORD )(s)) << 10) | (WORD )(p))
;#define PRIMARYLANGID(lgid) ((WORD )(lgid) & 0x3ff)
;#define SUBLANGID(lgid) ((WORD )(lgid) >> 10)
MAKELANGID MACRO pl:REQ, sl:REQ
LOCAL aVal, aOut
%aVal equ (sl SHL 10) or pl
aOut TEXTEQU %aVal
EXITM <&aOut>
ENDM
PRIMARYLANGID MACRO lgid:REQ
LOCAL aVal, aOut
%aVal equ (lgid and 03ffh)
aOut TEXTEQU %aVal
EXITM <&aOut>
ENDM
SUBLANGID MACRO lgid:REQ
LOCAL aVal, aOut
%aVal equ (lgid SHR 10)
aOut TEXTEQU %aVal
EXITM <&aOut>
ENDM
Enjoy
:alright:
NaN
Ok.. I've narrowed the problem to this:
Can anyone expain roughly how this would be casted into memory:
#define MAKEINTRESOURCEW(i) (LPWSTR)((ULONG_PTR)((WORD)(i)))
As i see it, I=number, trimmed to 16 bits, then refered by its address, and TOTALY unsure how the refered address turns into a string (unicode string).
Would it be a hex number for the address like "004040b8" in unicode? Or would it be the number stored at that address, like"123" in unicode?
Help!
:nan:
Can anyone expain roughly how this would be casted into memory:
#define MAKEINTRESOURCEW(i) (LPWSTR)((ULONG_PTR)((WORD)(i)))
As i see it, I=number, trimmed to 16 bits, then refered by its address, and TOTALY unsure how the refered address turns into a string (unicode string).
Would it be a hex number for the address like "004040b8" in unicode? Or would it be the number stored at that address, like"123" in unicode?
Help!
:nan:
Can anyone expain roughly how this would be casted into memory:
#define MAKEINTRESOURCEW(i) (LPWSTR)((ULONG_PTR)((WORD)(i)))
#define MAKEINTRESOURCEW(i) (LPWSTR)((ULONG_PTR)((WORD)(i)))
The WORD cast makes a WORD from i (it should already be one though).
ULONG_PTR casts it to the ULONG_PTR type, a type that guarantees enough bits to store a memory pointer.
LPWSTR casts the ULONG_PTR type to a the LPWSTR type.
The only thing that happens is casting of a value, nothing is referenced, the final value of the macro is the same as i, just casted to a specific type.
I think this should work:
ole32 pIGrammar, ISpRecoGrammar_LoadCmdFromResource, NULL, 123 , offset wzGRAMMER, dx, SPLO_DYNAMIC
btw, if you really want you can use a unicode string for a resource ID, but you need to prefix it with the sharp-sign (L"#123").
Thomas
P.S. PSDK on "MAKEINTRESOURCE":
....
Return Values
The return value is the specified value in the low-order word and zero in the high-order word.
....
:)Return Values
The return value is the specified value in the low-order word and zero in the high-order word.
....
Thanx!
I finally discovered this on my own. The :mad:*&^(#:mad: documentation is very missleading in this regard.
(WCHAR *) pszUnicodeString
doesn't say ULONG to me!!
As well, the required WORD for Language ID is also a ULONG type when calling from MASM... ((:mad:$#@#$:mad: Documentation))....
The working Solution is (using my above macros):
Thanx again for confirming this Thomas!
:NaN:
I finally discovered this on my own. The :mad:*&^(#:mad: documentation is very missleading in this regard.
(WCHAR *) pszUnicodeString
doesn't say ULONG to me!!
As well, the required WORD for Language ID is also a ULONG type when calling from MASM... ((:mad:$#@#$:mad: Documentation))....
The working Solution is (using my above macros):
[b]ole32 pIGrammar, ISpRecoGrammar_LoadCmdFromResource, NULL, 129, offset wzGRAMMER, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), SPLO_STATIC[/b]
Thanx again for confirming this Thomas!
:NaN:
NaN, this is a great place to seek ASM help.. but a specific thread name would of been expected from a moderator ;)
#define MAKEINTRESOURCEW(i) (LPWSTR)((ULONG_PTR)((WORD)(i)))
...and bibbety babbety boo. Put 'em together and what have you got? DWORD!!!!! I love ASM!
drhowarddrfinedrhoward, lol :grin:
huh, you are right. I will admit I tend to be pretty bad for that. But on the flipside, im not asking new questions too often :tongue:
NaN
huh, you are right. I will admit I tend to be pretty bad for that. But on the flipside, im not asking new questions too often :tongue:
NaN