accessing win32 c/c++ struct members c#
i am intercepting win32 api calls internal dll exe doing c# controlling kind hooking. sole box i am prying drawtext() user32.dll. announced win32 api:
int winapi drawtextw(hdc hdc, lpcwstr str, int count, lprect rect, uint flags)
the lprect struct following signature (also win32 api):
typedef struct tagrect {
enlarged left;
enlarged top;
enlarged right;
enlarged bottom;
} rect lprect;
long typedef 32bit integers 32bit systems (don't know 64bit systems, irrelevant during indicate since i am 32bit windows). means opening members struct i announced c# code...
[structlayout(layoutkind.sequential, container = 1)]
open struct rect
{
open int32 left;
open int32 top;
open int32 right;
open int32 bottom;
}
... wrote signature p/invoke controlling rect struct:
[dllimport("user32.dll", charset = charset.unicode, setlasterror = true, callingconvention = callingconvention.stdcall)]
static extern intptr drawtext(intptr hdc, twine str, int32 count, ref rect rect, uint32 flags, intptr dtp);
since structs value forms c# opposing being anxiety forms c/c++, ref modifier required here.
however i rect.top rect.left
etc, roughly always relapse 0. i know fact incorrect. nonetheless after googling large hours perplexing lot opposite things, i couldn't rudimentary things work.
things i've tried:
- using opposite primitives rect members (int, long, short, uint32...). indeed kinda apparent form problem since any box i should stammering numbers, 0.
- removing ref modifier. also ridiculous (desperate times, unfortunate measures) since rect.left justly advantage pointer rect instead the value.
- tried
unsafe
formula blocks. didn't work nonetheless i competence have finished mistake doing (i don't remember i've done). besides proceed generally indifferent machiavellian pointer situations com win32, profusion box anyway. - tried adding
[marshallas]
before members rect. finished difference. - played around
pack
values. difference.
i am sincerely certain i'm blank something unequivocally easy candid nonetheless i have thought is...
any assistance appreciated. conclude you.
Comments
Post a Comment