|
The segfault pretty much tells you that its a bad pointer. If you want to have a look at the properties of the memory address being passed you can do something like:
MEMORY_BASIC_INFORMATION mbi;
VirtualQueryEx(GetCurrentProcess(),pVar,&mbi,sizeof(mbi));
The member mbi.Protect will be probably be PAGE_NOACCESS. But of course you already have this knowledge.
Best Wishes,
-David Delaune
|
|
|
|
|
Yes it works fine.
Thanks a lot.
|
|
|
|
|
Are you calling it this way (assuming 'translate ' as the name of the function pointer)?
char * psz1 = "Hello";
char * psz2;
HRESULT hr = translate( psz1, psz2);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
yes. small change as below
char * psz1 = "Hello";
char * psz2 = NULL;
HRESULT hr = translate( psz1, psz2);
|
|
|
|
|
Well, psz2 initialization shouldn't matter.
Have you any documentation of the library?
(Maybe the function has some weird pre-requisite, like psz2 pointing to a client-allocated buffer...I know it doesn't make sense, but several real pieces of code actually does not make sense).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for replying soon.
The below logic given by Randor seems working.
MEMORY_BASIC_INFORMATION mbi;
VirtualQueryEx(GetCurrentProcess(),pVar,&mbi,sizeof(mbi));
if (mbi.Protect == PAGE_NOACCESS)
{
}
|
|
|
|
|
I'm glad about, but doesn't the HRESULT return value give some info about the translate operation?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Well, technically it could be other values. For example you may recieve a ramdom garbage pointer which resolves to a loaded PE image. A better implementation for checking a variable pointer would be:
MEMORY_BASIC_INFORMATION mbi;
VirtualQueryEx(GetCurrentProcess(),pVar,&mbi,sizeof(mbi));
if (mbi.Protect == PAGE_READWRITE && mbi.State = MEM_COMMIT && mbi.Type == MEM_PRIVATE)
{
}
This ensures:
1.) You can read and write to the address.
2.) The address is allocated and committed memory.
3.) The address is within the private region.
At this point the chance of being a good pointer has become substantially higher.
Best Wishes,
-David Delaune
|
|
|
|
|
I'm trying to obtain the Windows Firewall status, which is simple enough using the get_FirewallEnabled method on INetFwProfile. The problem is that this only retrieves the local policy, which could have been overridden by the group policy and so is sometimes wrong.
Does anyone know if there's a way of retrieving the group policy? There's a get_CurrentProfileType on INetFwMgr, but this just seems to return NET_FW_PROFILE_STANDARD regardless of the policy. There's a NEW_FW_POLICY_TYPE enum, but it's not used in any methods that I can find.
Thanks!
|
|
|
|
|
MSDN has examples for work with Firewall did you see
Using Windows Firewall API[^]?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Thanks. I'd read through this documentation, and can't find any way of obtaining the group policy (or indeed even of telling whether or not the local policy is being overridden). Given the existence of the NET_FW_POLICY_TYPE enum, I'd like to think it's possible, but I'm starting to think maybe it's not...
|
|
|
|
|
hello Experts,
I would like to know the basics of how to use SIP protocol using vc++.This is not regards to any project. Just for my self learning.
Thanks,
Himangshu
|
|
|
|
|
Do you know the wonderful CodeProject article search engine [^]?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
thx, I will go through it
|
|
|
|
|
Does it[^] helpful?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hamid. wrote: Does it[^] helpful?
Should be "Is it Helpful"...
anyway, happy new year Hamid, and congratulations for your new status
|
|
|
|
|
You grammar-nazi...
Happy new year tox!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: You grammar-nazi
no insults please
|
|
|
|
|
Thanks where are you old friend? and congratulations for your mvp again.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hamid. wrote: where are you
under my own work... no time anymore to roam on CP baords that much
|
|
|
|
|
Hamid. wrote: Thanks where are you old friend?
Tox deserted: you may find him togheter with the enemy, in the java forum...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
CPallini wrote: Tox deserted
I didn't I just don't have much time, and quite tired answering to google it or to look into an FAQ.
CPallini wrote: with the enemy, in the java forum
Java is not enemy not much than C# at least, so you'd better revise your judgement and spit at VB scripters instead.
|
|
|
|
|
toxcct wrote: Java is not enemy not much than C# at least
Java *is* the (MS) enemy, C# was invented to fight Java . (fighting VB scripters is like bombing the Red Cross ).
BTW: Did you notice the joke icon?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: Did you notice the joke icon?
anyway :
CPallini wrote: Java *is* the (MS) enemy
crap. everything is Ms enemy, but MS is not god, and it's not them to dictate to programers what language is best. I just want them to be a software producer, to produce good, not bugged things, and then people will nicely come to them. but that's definitely not the case currently. Java is a damn good language, but MS could not stand to have a free, well appreciated language aver the world and over the web, so they though they had to (once again) create their own version of something already existing...
CPallini wrote: fighting VB scripters is like bombing the Red Cross
you're rude. everybody knows what VB is, so please don't compare them to Red Cross, which is way more respectable than MS
|
|
|
|