|
So if I want to be sure and in the end come out with a measure of the number of bytes (since I use this in conjunction with a filename buffer for a custom multiselect file dialog) what can I do? Is there some other way of finding out the length in bytes of a string?
In a compile-mode independant manner? I mean it seems clear that the object itself contains a buffer so it should also internally have a count of the bytes. Is this hidden? Because this behaviour from GetLength() seems to be a bit confusing...
(or maybe I am what is confused?)
|
|
|
|
|
hello 2 all,
for my project i need to build a firewall by-passer for windows (2k & above) based on exploiting port 80 (HTTP encapsulation). the session will be opened with an external decapsulating server that will forward the original message, get the response & send it back to the source.
first:
does anyone knows an application that does that (with open source)?
second:
i think my first thing to do is to capture the outgoing packet & change it's destination ip & port while saving the original data inside the packet.
so, how can i do that, change fields etc..
third:
i wellcome any other suggetions on ways to implement this project.
p.s:
i read a lot of the things this site has to offer, but it's all very confusing & since i'm a begginer i would appriciate any help.
thanks.
|
|
|
|
|
Why would one want to bypass a firewall, especially on port 80 ?
~RaGE();
|
|
|
|
|
because the firewall allowes only http, but what if you want ftp or other applications? how do you by-pass the firewall restriction?
|
|
|
|
|
You don't!
Bypassing a firewall is a bad idea in most cases. One way to do such a thing is to write a low level driver that sends the data itself. This means that you have to write a driver on a lower level than the driver that is hooked by the firewall.
I think that the best way to accomplish the bypass of the firewall restriction, is to use an unusual port number and to state explicitly that any firewall or router should forward that port.
Bypassing the firewall doesn't work only temporary (the vendors of the software will fix the problem one day), but I'm sure that clients of your program won't like that feature. Especially changing the IP packet and sending it to another location...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
first of all, thanks!
second, i'm not trying to bypass the firewall that is on the same host as the application. i'm trying to bypass the firewall that is on the LAN edge, probably on a router (my university firewall to be exact). i can't tell if it's a regular firewall or is it combind with a proxy but i have to make it work anyway.
third, i know i have to write a driver & i searched for samples/tutorials in many websites, including pcausa.com & msdn. but because i'm new to this, i probably missed it, cause i know it's there somewhere.
|
|
|
|
|
avi-wildthing wrote:
nd, i'm not trying to bypass the firewall that is on the same host as the application
If you fireWall Allow you to communicate on Port 80 without problem, Then why not you simply use available WinInet Api! / Wrappers
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
ndis protocol driver is what you need.
Look at the windows 2003 DDk. There are samples there.
For out going packets you will need to change the TCP/UDP port address to the one you want, ie, the one blocked by the firewall.
For incomming packets change it back to the allowed port.
Make sure you driver sits between the NCI driver and tcpip.sys.
Now, to write the driver. Its a pain in the arse. It will take you about 6 months.
You will need to have 2 pcs to do the debugging over a serial link, to fix the 1000 blue screen your code will generate!
But, one you get it working it is very satisfying!
Nunc est bibendum!
|
|
|
|
|
Hi,
Does anyone know how to use hooking ?
For example: I think we can set up a hook to detect when a window of MSn messenger closes or starts.
Thanks
Preeti9
|
|
|
|
|
|
Can you please suggest me if hooking is a good approach to detect when a window starts and when it closes ?
Thanks
Preeti9
|
|
|
|
|
Preeti9 wrote:
Can you please suggest me if hooking is a good approach to detect when a window starts and when it closes ?
Yes I do think so. It is actually the only way to detect in the background if a window starts or closes.
~RaGE();
|
|
|
|
|
Thanks for the reply...
What if I use IsWindow function and then use while loop and at the end give sleep of like 1/2 a second....
Here is my program:
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
CTouchScreenAPI* pTouch;
// HWND hCalWin;
// DWORD SYNCRONIZE;
// DWORD procId;
HANDLE hProcess;
DWORD dwWaitResult;
pTouch = CTouchScreenAPI::Create();
if (pTouch)
{
if (pTouch->Init())
pTouch->Recalibrate();
else
MessageBox(NULL, "Created touchscreen interface OK, but Init() failed", "Info", MB_OK);
HWND hCalWin = ::FindWindow(pszABSPOINT_WND_CLASS_NAME, NULL);
//GetWindowThreadProcessId(hCalWin, &procId);
// retrieves the identifier of the thread that created this window.
// hProcess = OpenProcess(SYNCHRONIZE, FALSE, procId); //returns a handle to an existing process object
// Create top window class
//WinClass wc(ID_MAIN, hInstance,MainWndProc);
//hCalWin = wc.GetRunningWindow ();
// Is there a running instance of this program?
if (hCalWin !=0)
{
if( IsWindow(hCalWin) )
GetWindow(hCalWin, nCmdShow ); // handle of original window // relationship flag
//hCalWin->ShowWindow(SW_SHOW);
ShowWindow (hCalWin, SW_RESTORE);
while (1)
{
Sleep (1000);
}
return 0;
}
while (1)
{
dwWaitResult = MsgWaitForMultipleObjects(1, &hProcess, FALSE, 30*1000, QS_ALLINPUT);
if (dwWaitResult == WAIT_OBJECT_0 + 1)
{
MSG xMsg;
while (PeekMessage(&xMsg, NULL, 0, 0, PM_REMOVE))
{
if (xMsg.message == WM_QUIT)
return 1;
TranslateMessage(&xMsg);
DispatchMessage(&xMsg);
}// end of PeekMessage while loop.
int i=1;
while (i<10000)
{
i=i++;
}
}
else if (dwWaitResult == WAIT_TIMEOUT)
{
SendMessage(hCalWin, WM_CLOSE, 0, 0);
//TerminateProcess(hProcess, 0);
break;
}
else dwWaitResult == WAIT_OBJECT_0;
{
//Calibration process completed;
break;
}
}
}
else
{
MessageBox(NULL, "Unable to get pointer to Touchscreen interface", "Info", MB_OK);
}
return 0;
}
Help
Thanks
Preeti9
|
|
|
|
|
Also, I am getting an error in this....unresolved external....
Do I need to make this application a console one ?
Thanks
Preeti9
|
|
|
|
|
morning, all
I am looking at this code
CB_DBF_NTX* const p = OpenDbfNtxHelper( szDbfName, szIndexName, szIndexKey );
the P has value 0XCCCCCCC, if I do F10, it goes to
CB_DBF_NTX* pDbf = new CB_DBF_NTX( const_cast<char*>( szDbfName ) );
pDbf also has value 0xCCCCCCC.
does it mean p and pDbf BOTH need to be initialized or just pDbf?
thanks!
|
|
|
|
|
0xCCCCCCCC indicates an uninitialized local variable. If OpenDbfNtxHelper() fails, does it return a NULL pointer?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
thanks for your reply.
it will be returned void. and the OpenDbfNtxHelper will returned the valid adress.
so "0xCCCCCCCC indicates an uninitialized local variable", means oxCCCCCCC doesn't necessary cause moemory leak? thanks again!
|
|
|
|
|
valerie99 wrote:
so "0xCCCCCCCC indicates an uninitialized local variable", means oxCCCCCCC doesn't necessary cause moemory leak? thanks again!
never make that assumption.
every time you declare a pointer assign NULL to it; then you will be in better position to debug those kind of problems ( for example by using ASSERT )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
In this case
valerie99 wrote:
CB_DBF_NTX* const p = OpenDbfNtxHelper( szDbfName, szIndexName, szIndexKey );
the function probably fails and returns no pointer, but NULL .
In this case
valerie99 wrote:
CB_DBF_NTX* pDbf = new CB_DBF_NTX( const_cast( szDbfName ) );
pDbf should be a pointer on a new CB_DBF_NTX object, but the init also fails and returns NULL .
So the fact that both p and pDbf have a value of 0xCCCCCCC only shows that both pointers have the value NULL and are unititialized, but not that they are linked together in any way.
So the anwser to
valerie99 wrote:
does it mean p and pDbf BOTH need to be initialized or just pDbf?
is "Yes, both p and pDbf need to be initialized".
Check why your function OpenDbfNtxHelper and why the constructor CB_DBF_NTX fail (this has probably to do with szDbfName , which is common to both of the statements).
~RaGE();
|
|
|
|
|
remove the const, and do it in multiple instructions ( just for test ).
CB_DBF_NTX* p = NULL;
p = OpenDbfNtxHelper( szDbfName, szIndexName, szIndexKey );
ASSERT( p );
If p after the call to OpenDbfNtxHelper is still 0xffffffff check that the input to the function are valid.
Also, ALWAYS check that the pointers are valid, (before and) after an allocation with ASSERT .
usually, new will not fail.
are you certain you are running in DEBUG mode ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
valerie99 wrote:
I am looking at this code
CB_DBF_NTX* const p = OpenDbfNtxHelper( szDbfName, szIndexName, szIndexKey );
the P has value 0XCCCCCCC, if I do F10, it goes to
If you look at the value of p , while the instruction pointer is at this line, then you are seeing the value before this line has executed ; the value of p at this time is irrelevant. You need to look at the value of p after pressing F10
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
|
char szDescription[200];
BOOL bValid;
bValid= AfxIsValidString(szDescription, 400);
//bValid is TRUE, shouldn't it be FALSE?????????/
thanks
|
|
|
|
|
McGahanFL wrote:
...shouldn't it be FALSE?????????/
What makes you think so? This function tests the memory address to ensure that it is contained entirely within the program’s memory space.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
DavidCrow wrote:
This function tests the memory address to ensure that it is contained entirely within the program’s memory space.
I thought this was AfxIsValidAddress() , or maybe does AfsIsValidString call AfxIsValidAddress() ?
Anyway, I can understand that defining a string of 200 chars, and getting true when checking if it is valid for 400 chars is a bit disturbing, especially since the MSDN states :
Nonzero if the specified pointer points to a string of the specified size; otherwise 0.
~RaGE();
|
|
|
|