|
Use the TimeSpan class.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
hi
if i can't inject process to other process in c#.net , how to solve my problem ??
My problem is :
i want to write program that get one exe file and convert to dat file and create loader and checker file (3 file created : dat file,loader file and checker file)
loader file is almost blank process and when it executed , it check the checker file and if conditions is true the .dat file inject into loader until that orginal exe is run (like TZ Executable Protector)
//// How to do this ?
and if you have any idea for solve my problem (executable header,stream encryption/decryption or ...)
how to do that and give me an example or source ...
|
|
|
|
|
Why don't do drop this scheme and use a commercial product written by people who are Windows Internals professionals?? You're not going to get any answers that you consider "acceptable" and spamming the forums with the same question will not get you any closer to the answer. The technology that you're talking about is not just documented anywhere. In fact, it's NOT DOCUMENTED at all! There is a reason why these companies can charge what they do for a security wrapper like this!
It's clear that you don't have the black-belt-level of knowledge needed of the PXE file format, Windows Loader, unmanaged code, and what-not, to pull this off. And 99.9999% of the rest of the world doesn't either! You're trying to build something that is beyond the experience of most people you'll find on this, or any other board.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 16:52 Thursday 16th February, 2006
|
|
|
|
|
Dave Kreskowiak wrote: It's clear that you don't have the black-belt-level of knowledge
But he is persistant.
He's now changed tactic[^]. I'm now curious about what he is actually trying to build.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
I'll give him that much! But there comes a point in time where you just have to realize that the effort you putting into a project/feature to get a certain payoff just isn't worth the money you're pouring into it!
What's up with this guy??!! What's he tring to do with this junk??
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 20:17 Thursday 16th February, 2006
|
|
|
|
|
hi!
i've loaded two meshes and one of them should be 75% transparent
the other mesh moves behind that mesh.
i can see the backgroundcolor through the first mesh but i can't see the second mesh
after i created the device i set
dev.RenderState.SourceBlend = Blend.SourceAlpha;
dev.RenderState.DestinationBlend = Blend.InvSourceAlpha;
dev.RenderState.AlphaBlendEnable = false;
when i load the first mesh i enable the alphablend, draw the mesh and disable it again
if(meshMaterials[i].Ambient.A < 60)
dev.RenderState.AlphaBlendEnable = true;
mesh.DrawSubset(i);
dev.RenderState.AlphaBlendEnable = false;
what can i do to see the second mesh moving behind the first one?
thanks, kopi_b
|
|
|
|
|
it's very easy - when you know it...
first you have to render all the meshes with no transparency
then you can render the meshes with transparency and you'll see
the second mesh moving behind the first one
kopi_b
|
|
|
|
|
Hey...
I'm currently writing a Client/Server program in C#, which is used for sending files.
I'm using TCP, with asynchronous calls.
When I run 2 instances of my program, and initiate a connection with localhost, or when I use it on my LAN, or it works P-E-R-F-E-C-T!
However, I've tried it across the internet, and sometimes the transfer just stop.
After a long time of StepByStep, and other debugging methods, I've come to the conclusion that RANDOMLY, a pack is sent by one side, but NOT received on the other side, thus, stopping the "conversation".
I have a workaround idea, but I'm not too fond of it.
I can create a TimeOut timer.
It's job would be to send the pack repeatedly.
The timer would be started immediately after sending a pack,
and stopped immediately after receiving one.
I'll have to write code to check that I'm not analyzing the same pack over and over though.
Anywayzz...
Does anyone have an idea regarding WHY IT IS HAPPENING?!
Maybe another workaround, or just a comment about mine...?
|
|
|
|
|
Did you write a ping pong program?
It would help posting a bit of code. Also, do you use the same socket that Accepts to send back a packet. That would be the cause of your problem.
Assuming you are using the Socket class:
Socket newSock = serverSock.Accept();
newSock.Send(myPacket);
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
It's tough to post the code here... It's long...
Anyway... I have a global Socket named sck.
And if I got what you said... I think the problem is here:
<br />
private void acceptCallBack(IAsyncResult result)<br />
{<br />
try<br />
{<br />
sck = sck.EndAccept(result);<br />
byte[] data = new byte[2 * MAXBYTES];<br />
sck.BeginReceive(data, 0, data.Length, SocketFlags.None, new AsyncCallback(receiveCallBack), data);<br />
this.Invoke(new noParamsDelegate(connected));<br />
}<br />
catch { this.Invoke(new noParamsDelegate(idle)); }<br />
}
Is setting my sck to the returned socket wrong (sck = sck.EndAccept(result);)?
If so... than why is that a problem?
|
|
|
|
|
One problem I can see is that you don't close the Accept'ing socket, and you lose any reference to it (unless there is a hidden Socket variable also holding a reference to this socket).
I don't know if your acceptCallBack method is to be called repeatedly (like calling BeginAccept in loop), but if it is the case, you use a socket returned by EndAccept to accept new calls. This is wrong.
Another thing is that you receive data asynchronously. Would it be possible to see the receiveCallback method implementation?
Can I see the complete code where you BeginAccept call is?
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
-- modified at 20:06 Thursday 16th February, 2006
|
|
|
|
|
Michel Prévost wrote: I don't know if your acceptCallBack method is to be called repeatedly (like calling BeginAccept in loop), but if it is the case, you use a socket returned by EndAccept to accept new calls. This is wrong.
I'm not using the returned socket to accept new calls.
After disconnecting I close sck, and set it to null.
That way (I think ) I can instantiate sck AGAIN, and accept new calls.
My receiveCallBack() bellow takes every pack, and enqueues it in a global Queue named packs (Why?? --- I just like it )
I than dequeue them one by one in a timer, and send them to a function I called handleData().
I've taken out the loop block, as it's not essential for the discussion.
private void receiveCallBack(IAsyncResult result)<br />
{<br />
try<br />
{<br />
byte[] data = (byte[])result.AsyncState;<br />
short bytes = (short)sck.EndReceive(result);<br />
<br />
if (bytes == 0)<br />
{<br />
if (disconnectWait != null)<br />
disconnectWait.Set();<br />
this.Invoke(new noParamsDelegate(idle));<br />
}<br />
else<br />
{<br />
short currByte = 0;<br />
<br />
while (currByte < bytes)<br />
{<br />
<br />
packs.Enqueue(pack);<br />
}<br />
if (sck != null)<br />
sck.BeginReceive(data, 0, data.Length, SocketFlags.None, new AsyncCallback(this.receiveCallBack), data);<br />
}<br />
}<br />
catch { }<br />
}
Sorry the code isn't tabified.
This editor destroys it.
One more thing...
Michel Prévost wrote: One problem I can see is that you don't close the Accept'ing socket, and you lose any reference to it (unless there is a hidden Socket variable also holding a reference to this socket).
I didn't quite get that... Could you please explain it more detailed please?
How and where should I close it?
|
|
|
|
|
shyagam wrote: Sorry the code isn't tabified.
This editor destroys it.
Use <pre> tags.
shyagam wrote: Michel Prévost wrote:
One problem I can see is that you don't close the Accept'ing socket, and you lose any reference to it (unless there is a hidden Socket variable also holding a reference to this socket).
I didn't quite get that... Could you please explain it more detailed please?
How and where should I close it?
When done with a Socket, you must close it:
aSocket.Shutdown(SocketShutdown.Both);
aSocket.Close();
If you don't do that, the socket still holds the resources. Also, I noticed that you have an empty catch , this is very bad coding practice. You probably have an exception that would certainly help you debug your problem.
As of why it works if both apps are local and doesn't when on different machines, that is probably because of the different way windows handles TCP/IP communications when both apps are on the same host.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
-- modified at 9:02 Friday 17th February, 2006
|
|
|
|
|
Well... Let me show you another piece of my code...
private void performDisconnect(bool sendDisconnectionPack)
{
if (sck != null)
{
if (sendDisconnectionPack)
{
sendPack(CMD_DISCONNECT);
disconnectWait = new EventWaitHandle(false, EventResetMode.ManualReset);
disconnectWait.WaitOne(5000, true);
disconnectWait.Close();
disconnectWait = null;
}
if (sck.Connected) sck.Shutdown(SocketShutdown.Both);
sck.Close();
sck = null;
GC.Collect();
}
}
Hope it helps...
Hmm... BTW... What do you suggest to do with this:
sck = sck.EndAccept(result);
-- modified at 14:16 Friday 17th February, 2006
|
|
|
|
|
shyagam wrote: Hmm... BTW... What do you suggest to do with this:
sck = sck.EndAccept(result);
if you want to end accepting connections (maybe to resume later):
Socket tempSck = sck.EndAccept(result);
sck.Shutdown(SocketShutdown.Both);
sck.Close();
sck = tempSck;
Do you have the code for sendPack()?
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Well... It's a function I wrote...
Its purpose is creating a pack according to 2 parameters, and asynchronously send it.
I've taken out almost everything
It's a bit long, and you don't have to see the entire function to get the idea...
private void sendPack(byte command, byte param)
{
byte[] data, pack;
data = makePack(command, param);
sck.BeginSend(pack, 0, pack.Length, SocketFlags.None, new AsyncCallback(sendCallBack), null);
}
Here is the CallBack:
private void sendCallBack(IAsyncResult result)
{
try
{ sck.EndSend(result); }
catch(Exception ex)
{ this.Invoke(new stringDelegate(setStatus), ex.Message); }
}
lolz...
Looks like I WILL end up posting all the code :P
|
|
|
|
|
I forgot you wanted to see the code where my BeginAccept is...
Well... Here it is:
private void cmdListen_Click(object sender, EventArgs e)
{
if (cmdListen.Text == "Listen")
{
try
{
IPEndPoint ipEP = new IPEndPoint
(IPAddress.Any, int.Parse(txtPort.Text));
if (sck == null)
sck = new Socket(ipEP.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
sck.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
sck.Bind(ipEP);
sck.Listen(100);
sck.BeginAccept(new AsyncCallback(this.acceptCallBack), null);
listening();
}
catch (Exception ex)
{
setStatus(ex.Message);
this.Invoke(new booleanDelegate(performDisconnect), false);
}
}
else performDisconnect(false);
}
I can't remember though, And why I set the Listen() method's backlog parameter to 100, and why I wrote this line:
sck.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
Guess I'll end up posting the entire code here.
-- modified at 14:36 Friday 17th February, 2006
|
|
|
|
|
I've added the ability to access a word document using COM. However when I go to run this on another machine I get an error saying that my object is not set to an instace of an object. How come this would work fine on one machine (my development machine) and not on the other (testing)....here is my code
<br />
if (File.Exists("c:\\PO.dot"))<br />
{<br />
File.Copy("c:\\PO.dot", "c:\\PO1666.doc");<br />
oWord.Visible = true;<br />
object oFile = "c:\\PO1666.doc";<br />
oDocs = oWord.Documents;<br />
oDoc = (Word.Document) oDocs[1];<br />
oDoc = (Word.Document) oDocs.Open(ref oFile, ref oMissing,<br />
ref oMissing, ref oMissing, ref oMissing, ref oMissing,<br />
ref oMissing, ref oMissing, ref oMissing, ref oMissing,<br />
ref oMissing, ref oMissing, ref oMissing, ref oMissing,<br />
ref oMissing, ref oMissing);<br />
<br />
The error comes up when I open the document.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
never mind. Didn't see the openold method.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
|
I have a network application that is reading an incomming message. The message should be UTF-8 formatted and could be transfered with garbage. I am currently using the StreamReader and BinReader to read from the stream, but I am unsure if I am using these objects properly.
When I use the StreamReader to ReadToEnd() will it stop when it has reached an incomplete character?
Will it leave the stream position after these incomplete characters, or will it go past them and just not include them in the results?
Assert(this);
|
|
|
|
|
This is from MSDN:
ReadToEnd works best when you need to read all the input from the current position to the end of the stream. If more control is needed over how many characters are read from the stream, use the Read(Char[],Int32,Int32) method overload, which generally results in better performance.
ReadToEnd assumes that the stream knows when it has reached an end. For interactive protocols, in which the server sends data only when you ask for it and does not close the connection, ReadToEnd might block indefinitely and should be avoided.
Note than when using the Read method, it is more efficient to use a buffer that is the same size as the internal buffer of the stream. If the size of the buffer was unspecified when the stream was constructed, its default size is 4 kilobytes (4096 bytes).
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hmm, I'll try changing it to Read. I'm guessing that an incomplete character could cause a block, I guess I'll just have to waste the memory in triple allocation (stream, array, string). It's kind of hard to specify a buffer that is the same size as the stream though since with multibyte I won't know the number of chars that are actually in the stream until it's decoded.
Assert(this);
|
|
|
|
|
Is there anyway of specifying the order that properties will appear in a property grid? I know how to create property categories but i wish to order the properties in the category.
Cheers
Mark.
|
|
|
|
|
I think that there is no way to define order of properties in the property control. It sorts properties alphabetically in each category.
Look at MSDN Property Control
|
|
|
|
|