|
Does any1 have an idea on how I could simulate a CPU clock in .NET?Specifically i want to simulate the ticks of a CPU clock,as part of a program that handles processes in terms of an OS...The algorithms that i want to implement have as criteria the arrival time of process in a CPU and the burst time..So i need something to count-To simulate the CPU clock..I used to do that with "time.h " in VC++ 6 but now i don't know how...
Pls Help & keep up the good work...
May it be your fate to live in interesting times
|
|
|
|
|
This may not be useful to you, it depends on what kind of accuracy you need.
In Feng Yuan's book (Windows Graphics Programming), he implements a timer with readout to produce time intervals that the operating system took to complete a GDI function calls. He used the processor's own registers and wrote most of the code in assembly. In all honesty, I didn't understand the specifics of his method, but, he was reporting time spans in microseconds. As I recall, it was a hook method, and the tricky part was returning the registers to their original value, so that the application could then time other functions.
I'm guessing you'd want something simpler and fool proof.
|
|
|
|
|
OK, essentially my friend has a game server I want to send packets to. I have no clue where to begin, but what I want to do is establish a connection with the actual game, and then have another program intervene.
It should then:
Log all packets sent from the game and spoof packets back to it.
Log all packets sent from server and spoof packets back to it.
Can this be done?
|
|
|
|
|
I am going to assume that the program uses SOCK_STREAM and not something else. Im also going to assume that your on a windows system. There are two suggestions I have for you... neither of them answer your question fully, but they might nudge you in the right direction.
Hobbit and Weld Pond built a great tool called netcat... it is command line and can be plugged in to other applications with minimal ease. It supports a hex dumping feature (not quite packet logging though) although I am sure that you (or some else) could code a packetlogging option into it.
The other option involves the ethereal program (packet logger) which obviously logs packets... analyse the pckets for a while and see what comes up when something happens. Then use a packet crafter... I'm sure I saw one around here the other day, and send your spoofed information... If you were really smart you would code your own tool to incorporate these idea's and save you installing a hundred programs just to make the thing work.
I don't claim to know all the answers, I claim to be able to bs enough to help people out...
|
|
|
|
|
Hi,
I am trying to use the getprocessesbyname manged extension from the system:diagnosics system.dll
from .NET with C/C++
Do any one knows away to get for a speacific process name how many process currently running and then use it in an unmanage project.
I don't want to define it with complier \clr and then use #pragm unmange and mange,tried it already and the rest of the project didn't compile.
And the only way I had luck of using it by creating a manage project and
using this code:
[C++]
#using <mscorlib.dll>
#using <system.dll>
using namespace System;
using namespace System::Diagnostics;
int main()
{
//process running eyal.exe
Process* localByName[] = Process::GetProcessesByName(S"eyal");
}
I just want to be able to run only one program eyal.exe ,and if try to run more then one will have a message and then terminate the second process.
Thanks
Will be glad to get any help.
|
|
|
|
|
I am new to the Managed C++,I have created a namespace "N" with one "Cl" class in that name space.
Now I want to use this "Cl" as a data memeber in a unmanaged C++ class.
the syntax i have followed in Unmanaged c++ class header is as follows..
class Unmanged
{
public:
Cl *m_Managed;
};
The reported error is..
error C3265: cannot declare a managed 'm_Managed' in an unmanaged 'Unmanaged'
Please help in solving this is very urget for my assignement.. Thanks.
|
|
|
|
|
Are both of these classes in the same application? Is the unmanaged class a COM object?
At any rate, when you transfer data to and from managed and unmanaged types or call functions again from managed to unmanaged, or from unmanaged to managed classes or objects, the Interop marshaler takes care of some operations (invisibly from the programmer's point of view). Generally, this involves some data transfer and the marshaler tries to convert defined types to their compatible types in the other domain. The marshaler, because it deals with so many different and disparate types has a well-designed behavior. User-defined types are the most difficult to deal with and sometimes it is necessary to write a custom marshaler to enable the Interop to work properly.
There is lots of information over at the MSDN site.
And, in all honesty, I am not that experienced in this area, but, it is common to experience problems with Interop.
I have been reading: "NET and COM: The Complete Interoperability Guide", by Adam Nathan, and I would highly recommend it as a source of 'official' Interop intel.
A simple suggestion, though: use the same types for your data in both managed and unmanaged classes, and re-write your functions so that they accept those data members, rather than the class.
|
|
|
|
|
|
Help me,please.
Thanks a lot.;P
|
|
|
|
|
What do you want to do ? Why are you asking in a managed C++ forum ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Help me,please.
Thanks a lot.;P
|
|
|
|
|
Hai,
In my application i want to rotate the Polygons i have drawn in a specifeid angle without using the RotateTrasnfom(bcoz a lot of other object are in my drawings).
Nanyone have any idea about it?
Thnaks in Advance
|
|
|
|
|
Don't you just rotate, draw, then rotate back ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hi! I'm trying to write a grayscale 8-bit BMP file header (without using special classes and without specifying color table). For example, I want to know the way that Windows's mspaint.exe writes the grayscale-headers. I have learned the specifications for writing a header for RGB (24 bit) bitmap, but I couldn't change the values for the grayscale one. Maybe there are several specifications and I use the wrong one (i.e it is valid only for RGB bitmaps). Could anyone help me with this problem?
Thanks in advance!
|
|
|
|
|
Create two simple 1*1 black and 1*1 white bmps and see the header in some hex editor!
It will work!
Kamyar Souri
Booria CAD/CAM Systems
www.booria.com
|
|
|
|
|
i'm quite new to managed c++, so sorry for the question, but: can i have an unmanaged function within a managed class? specifically, i'd like to declare a variable (if i can have it as a member, even better) using a __declspec , while keeping my class managed.
Any help would be much appreciated.
there are no facts, only interpretations
|
|
|
|
|
I have seen examples of C++ unmanaged classes in extension DLLs, wrapped successfully with managed C++ classes, also in their own DLL, so that the managed classes can be called from C#. However, every example I have seen uses an unmanaged class that does not use any MFC. For example, I cannot find a single example (and have so far failed to create one myself) of an unmanaged C++ class that has some functions with CString arguments and/or return values, wrapped by a managed C++ class in a DLL, callable from C#. If anyone has such an example, I'd be forever grateful to receive it. When I try it, IJDW (it just doesn't work). I can get everything to compile file, but when I try to pass a string from the C# program down through the MC++ DLL to the unmanaged C++ DLL, I get an exception down there at the bottom saying that the object reference is not set to an instance of an object, even though I can see that the passed in string is just fine.
Thanks for any assistance.
|
|
|
|
|
Unfortunately, I don't use MFC in my coding projects, so my advice will be somewhat incomplete. We get this problem alot in Interop operations when passing data (often strings or structs) to native pre-.NET C++ functions in compiled DLLs.
The basic problem is the way the Interop marshaler processes the data; the default behavior has limited applicability with user-defined data structures. This is particularly a problem in COM, as many of the data structures are defined as types that have no compatible type in .NET.
The solution in .NET is to use attributes to control the marshaling behavior of the Interop when the default behavior is inappropriate, as in this case.
I suggest that you review the MarshalAs(UnmanagedType) attribute documentation over at MSDN. In all honesty, I don't what the correct usage would be, but, hopefully you won't have to write a custom marshal routine (because it's such a pain in the ass).
Try reading this: Deafult Behavior for Strings:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondefaultmarshalingforstrings.asp[^]
..or, this, the MarshalAs(UnmanagedType) Enumeration:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemruntimeinteropservicesunmanagedtypeclasstopic.asp[^]
|
|
|
|
|
I declared a few strings for a managed class:
public __gc class class1
{
public:
// function
String *string1;
String *string2;
};
Then in the contructor, I allocate memory for those string:
class1::class1()
{
string1 = new String("");
string2 = new String("");
}
But when I use them, the program is not stable, sometimes it just throw an exception on those string. I think I need to allocate enough memory for those string. How do I allocate memory for a string with specify length?
Thanks
|
|
|
|
|
I created a c++ object and exported the funtion I wanted to use with dllexport. Then created a managed wrapper that linked with my unmanaged
code. I used c# Windows application that made use of the managed wrapper.
All this works fine. Yipee
Now i am trying to export the entire c++ object. SO i have
//------------------------------------------------------
class __declspec(dllexport) Sum
{
public:
Sum();
~Sum();
public:
double Add( double num1, double num2 );
};
//------------------------------------------------------
Is it possible to export the entire class.
Now the MC++ was
//------------------------------------------------------
extern "C"
{
double Add( double num1, double num2 );
}
//--namespace stuff and other declaration
__gc class Class1
public: double DoAdd( double n1, double n2 )
{
return Add( n1, n2 );
}
//------------------------------------------------------
My question is what do I replace the extern "C" part with now and assuming that I dont have the source code for the c++ code, just the dll
and lib files.
|
|
|
|
|
Hi everybody, I'm a student, and I'm triying to create the tree command like int DOS, to print all the directories and files of my hard disk, but I can't .I must use "findfirst" and "findnext" function in Turbo C++ (3.0).
Please, help me!!! doh:
|
|
|
|
|
Well, I think I'd be right in saying that Turbo C++ does not support managed C++. You should find a forum that supports your compiler ( although from memory, firdfirst and findnext are Windows API functions, which means it shouldn't matter ). Your solution will be recursive, it will call itself whenever it finds a folder to move into.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I've created MFC Application using Visual Studio 2003, then change the project settings
to use Managed Extensions as follows:
1. Configuration Properties->General->use Managed Extension : Yes
2. C/C++->General->Debug Information Format : Program Database (/Zi)
3. C/C++->Code Generation->Enable Minimal Build : No
4. C/C++->Basic Run-Time Check : Default
then in the CMyClassDlg.cpp did the following:
#using <mscorlib.dll>
#using <system.dll>
using namespace System;
#using <system.xml.dll>
#using <system.data.dll>
and in the OnInitDialog() did :
XmlDocument *xmlDoc = new XmlDocument();
//Just this to try
and compile this error message appeared:
(105): error C3828: 'System::Xml::XmlDocument': placement arguments not allowed while creating instances of managed classes
I dont know why this error generated ,though I did the same thing in my ISAPI Filter DLL project and used XmlDocument
and SqlClient effectively.
why this happening in MFC application .
Any Idea? Regards.
|
|
|
|
|
this the directive the check box for using < as HTML was not checked
#using <mscorlib.dll>
#using <System.dll>
using namespace System;
#using <System.Xml.dll>
#using <System.Data.dll>
|
|
|
|
|
Hi!
I need to get the names and parameters of the functions out of an compiled dll.
thanks in advance
thomas
|
|
|
|