|
Hi.
Does anybody know how to make a executable VC++ file
with a built in dll hook?
cause i get tired of using a loader, so i wanna try this.
greetz
DP
|
|
|
|
|
|
thnx for your reply.
i want to hook my DLL into another application.
the dll itselfs works, so i use an injector.
the problem is i want to do this in one exe which "contains" my dll, so i don't need the loader.
greetz
DP
|
|
|
|
|
I would like to make a DLL with template functions and classes. How this can be done?
Thank you
DO!
|
|
|
|
|
templates can be defined only in h file, so they can not be in dll.
this is c++ syntax, no other choices.
includeh10
|
|
|
|
|
Templates are used by the compiler to "copy and paste" the code for datatypes that are used with a particular function. By the time it becomes a dll, there is no more need for the template.
|
|
|
|
|
Hi!
I want to start/stop windows service from my C++ program. How do I do that? I searched google but found nothing
Thanks!
Regards,
Iliya Yordanov
www.csharp-home.com - C# Resources
|
|
|
|
|
To start a service, use the StartService API function. To stop, pause, or continue it, use the ControlService API function.
|
|
|
|
|
|
I am very sorry because my english is too bad!!!
I need some code optimizer (can check and warn about run-time error in my source code).
Thank you very much!
maiquan
|
|
|
|
|
Doesn't the normal Visual Studio debugger/compiler do the job?
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
Hi,
After many years, I've started developing C++ app to log into another server and perform some tasks. I'm getting the error 1314 (A required privilege is not held by the client), when I execute LogonUser function. Before I'm getting error 1300 (Not all privileges referenced are assigned to the caller), when I execute AdjustTokenPrivileges. I'm thinking that this error 1300 is triggering the error 1314. How can I get rid of these errors? FYI, I'm trying to log into my local machine with the local username/password (LOGIN/PASSWORD). This is a Win 2k pro machine, which is not part of any domain. I'm observing all these error codes while stepping thru the code in MS Visual env.
Last point is, LookupPrivilegeValue is returning an error code of 997 (Overlapped I/O operation is in progress). Could this also be causing the current problem?
Any help or pointer in resolving my current issue is greatly appreciated. Have a nice day & week ahead!
Code snippet:
char *szUserName = (char*)malloc(65);
char *szDomain = (char*)malloc(65);
char *szPassword = (char*)malloc(65);
strcpy(szUserName, "LOGIN");
strcpy(szDomain, ".");
strcpy(szPassword, "PASSWORD");
DWORD dwSize = 50+1;
char szUser[50+1]={0};
PROFILEINFO MyProfile = {0};
LUID Luid;
//The following stmt is throwing error 997 (Overlapped I/O operation is in progress)
if(!LookupPrivilegeValue(NULL, SE_TCB_NAME, &Luid))
{
OutputDebugString("LookupPrivilegeValue failed.\n");
iLastError = GetLastError();
goto Exit;
}
HANDLE hProcToken;
if(!OpenProcessToken(
GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY|TOKEN_DUPLICATE,
&hProcToken))
{
OutputDebugString("OpenProcessToken failed.\n");
iLastError = GetLastError();
goto Exit;
}
TOKEN_PRIVILEGES TokenPriv;
TokenPriv.PrivilegeCount = 1;
TokenPriv.Privileges[0].Luid = Luid;
TokenPriv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
//The following stmt is throwing error 1300 (Not all privileges referenced are assigned to the caller)
if(!AdjustTokenPrivileges(
hProcToken,
FALSE,
&TokenPriv,
0,
NULL,
NULL))
{
OutputDebugString("AdjustTokenPrivileges failed\n");
iLastError = GetLastError();
goto Exit;
}
// Log on as user with valid credentials for accessing the Exchange server.
//The following stmt is throwing error 1314 (A required privilege is not held by the client)
if (!LogonUser(
szUserName,
szDomain,
szPassword,
LOGON32_LOGON_SERVICE,
//LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
&hToken))
{
OutputDebugString("LogonUser failed.\n");
iLastError = GetLastError();
goto Exit;
}
Thanx,
harish
|
|
|
|
|
Hi,
It's probably stupid question,but how can i change the tabs order in my dialog?
Regards,
Eli
|
|
|
|
|
In the dialog editor, just press Ctrl+D, and the current tab order is displayed with each control having a numeric label. Just click on each control in the order you want to change the order.
|
|
|
|
|
Finally..........
Thanks,
Eli
|
|
|
|
|
An extra tip would be renumbering a control after the complete dialog is set.
If you want to later change the tab order in the dialog editor press CTRL+D to show the tab numbers then hold the CTRL key down and clik on the item before you want to begin renumbering. Then release the CTRL key and the next item you click on will start with the number after the item you just clicked. So if you have 55 items and you need to renumber after the 30th one no need to start over. Just press CTRL click on the 30th release the CTRL and away you go.
|
|
|
|
|
Hi,
I want to be able to toggle between bitmaps each time the button (in a toolbar) is being clicked. How should I do it?
thanks,
yaron.
|
|
|
|
|
check thiz ......
http://www.codeproject.com/bitmap/bmpscroll.asp[^]'
u should find usful information in that....just got to modify that a little bit.....
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
Currently, I have a COM event which I've created a sink for and all of that jazz. It receives events at the Invoke method of course. Then i use dispIdMember to figure out which event was called. The only problem is that the event is fired from a different thread as the rest of my program, which poses a huge problem. Is there a way that I can call a function on threadA from threadB?
|
|
|
|
|
Hello, all.
I have some comments about linked lists & arrays and locality of reference.
Adding a node to a list a traditional method:
allocate each node using the new operator, then hook it into the list using "prev" and
"next" pointers.
This is fine, except that if you traverse the list a lot, accessing each node could
caused a missed cache hit or page fault, degrading application performance.
However, using an array-based structure to hold each data element offers much better locality of reference (all the nodes and data in one big allocation).
The drawback here is that it is harder to grow the array (reallocate to the new size,
then copy all the stuff over).
If you are not sure of how many nodes the list will contain, or if the data is some
complex structure, you may want to use a traditional method.
If you know exactly what the maximum capacity will be or if the data structure is
an fairly simple, and you traverse the list a lot, it may be worthwhile to store the
nodes in an array.
What it really concludes to, is it depends on what you are trying to do.
What do you all think?
|
|
|
|
|
When using a linked list, there is also the strategy of allocating chunks of memory that are multiples of your node size. For example, if you have a list of int (so your node size is 8, 4 for the int and 4 for the 'next' pointer), you could allocate memory in blocks of 8*N, where N is some "good" number you arrive at through perf measuring tools. Then when you add a node, you take that block and use the next available 8 bytes for the node. If you've used up a whole block, allocate another block and start using that.
MFC does this with its collections, the class that handles the chunks of memory is called CPlex (it's not documented, so you'll need to read the source).
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Thx, Mike! Found CPlex, indeed, in the MFC source.
Allocating blocks is not a bad idea, locality of reference is still relatively good, and you don' have to copy previous elements! That's not a bad idea; sort of the best of both worlds!
|
|
|
|
|
VC++ relationship between low-level objkects and GUI interfaces Question.-
Suppose I have base class A. And subclasses A1, A2, and A3.
class A {...}; // abstract class
class A1 : public A {...}
class A2 : public A {...}
class A3 : public A {...}
I want to allow a user edit A1, A2, or A3 properties through a Dialog Box. Though I have A1Dlg, A2Dlg, A3Dlg:
class A1Dlg : public CDialog {...}
class A2Dlg : public CDialog {...}
class A3Dlg : public CDialog {...}
Then, in my program, I have a list of A object pointers (where I actually have A1, A2 or A3 objects).
// this lines are to explain what I mean, not real code.
// Objects are not instantiated this way, how they are
// created depends on several factors.
A* m_list[n];
m_list[0] = new A1();
m_list[1] = new A3();
m_list[2] = new A2();
...
Question: because my A classes are very "low-level" they don't even know there exists a GUI, or a CDialog class. How can I show the correct Dialog using m_list?
I don't want to do A::displayDialog() because my A classes are very lo-level, they don't know a GUI exists, and they also run on Linux, and win cmd line. Besides that, I want objects to know as less as possible of the rest of the world (don't know if this is conceptually correct in com`puter design). This discards the chance to do:
m_list[x]->displayDialog()
Ugly solution: my solution (very, very ugly) was to declare a methods getType() this way:
enum { a1, a2, a3 } types_t;
types_t getType() = 0; // A class declaration
types_t A1::getType() { return a1; } // A1 implementation
types_t A2::getType() { return a2; } // A1 implementation
types_t A3::getType() { return a3; } // A1 implementation
And I have a "controller" that display the correct dialog box using a switch:
switch (m_list[n]->getType) {
case a1:
// display A1Dlg;
break;
case a2:
// display A2Dlg;
break;
case a3:
// display A3Dlg;
break;
}
Yeah! It is not nice. But This way I have very well separated the data objects (A1, A2, A3) and the view objects (A1Dlg...).
Yes, I've read MVC, but I can't figure it out how to do this "match" in an elegant way.
Can anybodey help? Thanks a lot!
|
|
|
|
|
You have to enable some from of RTTI (Run Time Type Information). The way you did it is ok, but you are probably better off using the built in way. Look up RTTI, /GR, and dynamic_cast in MSDN.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hi Everybody,
I have problem with global functions in VC++.Net, is simply
add a global function in my project like:
UINT MyThreadProc(LPVOID pParam)
{
...
return 0;
}
and then when i want to call it for example when pressing abutton : AfxBeginThread(MyThreadProc,0) , i get an error :
c:...: error C2065: 'MyThreadProc' : undeclared identifier
can anyone help ?
Regards
Giorgi Moniava
|
|
|
|
|