|
wait. im sorry about that. this is the right code.
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main(){
stack<string> syntax;
string word;
while (cin >> word)
{
syntax.push(word);
}
cout << "Number of words: " << syntax.size() << endl;
while(!syntax.empty())
{
cout << syntax.top() << endl;
syntax.pop();
}
cout.flush();
return 0;
}
|
|
|
|
|
Hi All,
I want to attempt to block a specific program from establishing outgoing TCP/UDP connections. Thus as the (external) app attempts to make a socket connection, I want to receive notification of the event and have the ability to allow or deny the connection attempt.
(I know this is basic firewall functionality I am referring to here, but there is no firewall on the market that can do exactly what I want, when I want, and how I want it for this specific program)
I have seen the packet filtering API that is provided by Windows, but that only seems to filter on IP's and Ports. I want to filter on application !
Can anybody please point my nose in the right direction here.
Thanks
OD
VC++ .NET 2002 on Windows XP and above ...
|
|
|
|
|
Try implementing a Layered Service Provider. This is a DLL that gets loaded by every application that uses Winsock.
Look up Winsock Layered Service Provider, or LSP.
“Cannot find REALITY.SYS...Universe Halted.”
~ God on phone with Microsoft Customer Support
|
|
|
|
|
Hi all,
I am currently working a specific hardware device and the device header files do not support some of the standard C string routines. Thus I am struggling to convert a int to a char* .
Thus, how can I perform this action without making use of itoa, printf, sprintf ??
Many thank in advance
Kind regards,
The only programmers that are better those C programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
modified on Wednesday, October 22, 2008 10:38 AM
|
|
|
|
|
Examine the source code of a standard C-RTL and steal^H^H^H^H^H , er... get some inspiration from... their implementation.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Here's how the CRT does itoa(), with all the error/buffer overflow checking stripped...
void integertoascii(int n, char *buf, int radix)
{
char *pbuf = buf;
do
{
unsigned int digit = (unsigned int)(n % radix);
n /= radix;
if (digit > 9)
*pbuf++ = digit - 10 + 'a';
else
*pbuf++ = digit + '0';
}
while (n > 0);
*pbuf-- = '\0';
do
{
char temp = *pbuf;
*pbuf = *buf;
*buf = temp;
--pbuf;
++buf;
} while (buf < pbuf);
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am installing my mfc based application through a .msi file.
i want to know how to close a running application before uninstallation???
|
|
|
|
|
Implement a small DLL that closes the application by sending a WM_CLOSE message to the main window.
Then call the DLL through a Custom Action in your MSI.
“Cannot find REALITY.SYS...Universe Halted.”
~ God on phone with Microsoft Customer Support
|
|
|
|
|
Hi Richard,
I got your point.Can you give me some detail info may a sample code as i am new to this thing.
Tarun.
|
|
|
|
|
Hello everyone,
How to get the preferred load address for a DLL? Suppose I just have the binary DLL and no source code?
thanks in advance,
George
|
|
|
|
|
You can use ListDLLs[^] to list currently loaded dlls.
If you use the -r switch it will flag up any dlls that have been relocated, and give you their preferred base.
Or Process explorer[^] has a dlls window which lists all the dlls loaded for each process, their base address, their preferred base address, and colours them yellow if they have been relocated.
Simon
|
|
|
|
|
Hi Simon,
Which Window in Process Explorer lists loaded DLLs for a process? I can not find out.
regards,
George
|
|
|
|
|
From the view menus, select the "Show lower pane options"
Then again from the view menu select "view->Lower pane view->dll"
|
|
|
|
|
Thanks nave,
DLL is displayed, but the DLL properties only display load address, no preferred load address. Any comments?
regards,
George
|
|
|
|
|
You can select that column also.
take the select column option by right clicking on the header of the lower pane. Select the "Base" and "Image Base" from the list. The "base" is the address at which the dll has actually loaded and "Image base" is the prefered base address.
You can also use the dependency walker to find the prefered base address.
|
|
|
|
|
Thanks nave!
I have found out, very good tool!
regards,
George
|
|
|
|
|
On my system at least,
dumpbin /headers iain.dll
then look at the image base value.
That's with VS6 - no idea if the utility is still around for later versions.
Iain.
|
|
|
|
|
Hi Iain,
Here is my output, which item do you think is the preferred load address?
Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file TestDll2.dll
PE signature found
File Type: DLL
FILE HEADER VALUES
8664 machine (x64)
7 number of sections
48FF2B43 time date stamp Wed Oct 22 21:31:47 2008
0 file pointer to symbol table
0 number of symbols
F0 size of optional header
2022 characteristics
Executable
Application can handle large (>2GB) addresses
DLL
OPTIONAL HEADER VALUES
20B magic # (PE32+)
9.00 linker version
4800 size of code
3600 size of initialized data
0 size of uninitialized data
1520 entry point (0000000180001520) _DllMainCRTStartup
1000 base of code
180000000 image base (0000000180000000 to 000000018000CFFF)
1000 section alignment
200 file alignment
5.02 operating system version
0.00 image version
5.02 subsystem version
0 Win32 version
D000 size of image
400 size of headers
F212 checksum
2 subsystem (Windows GUI)
140 DLL characteristics
Dynamic base
NX compatible
100000 size of stack reserve
1000 size of stack commit
100000 size of heap reserve
1000 size of heap commit
0 loader flags
10 number of directories
7DB0 [ 16A] RVA [size] of Export Directory
A000 [ 3C] RVA [size] of Import Directory
B000 [ 2B8] RVA [size] of Resource Directory
9000 [ 288] RVA [size] of Exception Directory
0 [ 0] RVA [size] of Certificates Directory
C000 [ 3C] RVA [size] of Base Relocation Directory
6550 [ 1C] RVA [size] of Debug Directory
0 [ 0] RVA [size] of Architecture Directory
0 [ 0] RVA [size] of Global Pointer Directory
0 [ 0] RVA [size] of Thread Storage Directory
0 [ 0] RVA [size] of Load Configuration Directory
0 [ 0] RVA [size] of Bound Import Directory
A2A0 [ 260] RVA [size] of Import Address Table Directory
0 [ 0] RVA [size] of Delay Import Directory
0 [ 0] RVA [size] of COM Descriptor Directory
0 [ 0] RVA [size] of Reserved Directory
SECTION HEADER #1
.text name
4687 virtual size
1000 virtual address (0000000180001000 to 0000000180005686)
4800 size of raw data
400 file pointer to raw data (00000400 to 00004BFF)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
60000020 flags
Code
Execute Read
SECTION HEADER #2
.rdata name
1F1A virtual size
6000 virtual address (0000000180006000 to 0000000180007F19)
2000 size of raw data
4C00 file pointer to raw data (00004C00 to 00006BFF)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
40000040 flags
Initialized Data
Read Only
Debug Directories
Time Type Size RVA Pointer
-------- ------ -------- -------- --------
48FF2B43 cv 57 0000702C 5C2C Format: RSDS, {FC74C901-7889-4E77-8E4F-C81674668F9A}, 1, d:\Visual Studio 2008\Projects\TestDll2\x64\Debug\TestDll2.pdb
SECTION HEADER #3
.data name
759 virtual size
8000 virtual address (0000000180008000 to 0000000180008758)
200 size of raw data
6C00 file pointer to raw data (00006C00 to 00006DFF)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
C0000040 flags
Initialized Data
Read Write
SECTION HEADER #4
.pdata name
3F0 virtual size
9000 virtual address (0000000180009000 to 00000001800093EF)
400 size of raw data
6E00 file pointer to raw data (00006E00 to 000071FF)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
40000040 flags
Initialized Data
Read Only
SECTION HEADER #5
.idata name
9C1 virtual size
A000 virtual address (000000018000A000 to 000000018000A9C0)
A00 size of raw data
7200 file pointer to raw data (00007200 to 00007BFF)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
C0000040 flags
Initialized Data
Read Write
SECTION HEADER #6
.rsrc name
2B8 virtual size
B000 virtual address (000000018000B000 to 000000018000B2B7)
400 size of raw data
7C00 file pointer to raw data (00007C00 to 00007FFF)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
40000040 flags
Initialized Data
Read Only
SECTION HEADER #7
.reloc name
F7 virtual size
C000 virtual address (000000018000C000 to 000000018000C0F6)
200 size of raw data
8000 file pointer to raw data (00008000 to 000081FF)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
42000040 flags
Initialized Data
Discardable
Read Only
Summary
1000 .data
1000 .idata
1000 .pdata
2000 .rdata
1000 .reloc
1000 .rsrc
5000 .text
regards,
George
|
|
|
|
|
This one:
180000000 image base (0000000180000000 to 000000018000CFFF)
Simon
|
|
|
|
|
Thanks for your clarification, Simon!
regards,
George
|
|
|
|
|
George_George wrote: Here is my output, which item do you think is the preferred load address?
In the middle of the first "Lump":
180000000 image base (0000000180000000 to 000000018000CFFF)
Though I'd look at the sysinternals tool, as they're more digestible!
Iain.
|
|
|
|
|
Thanks for sharing your perspective, Iain!
regards,
George
|
|
|
|
|
HMODULE hModule=LoadLibrary("Drive:\\folder\\sth.dll");
if(!hModule)
{
MessageBox("Load sth.dll failed!);
return;
}
FARPROC address= GetProcAddress(hModule, ("Drive:\\folder\\sth.dll");
if(!address)
{
MessageBox("GetProcAddress failed!);
return;
}
|
|
|
|
|
Hi anminxin,
Sorry I disagree with your code. I am asking how to get the preferred load address, but you get the actual load address. Any comments?
regards,
George
|
|
|
|
|
Hi,
I have a C code that calls an assembly procedure with a parameter that is a pointer to a structure.
typedef struct _SOMESTRUCT {
ULONG arg1;
CHAR arg2[10];
} SOMESTRUCT, *PSOMESTRUCT;
Then in C code, im calling an assembly proc like this:
SOMESTRUCT mySomeStruct;
ret = AssemblyFunction(&mySomeStruct);
In assembly code, how can i access arg1 and arg2?
Any idea?
|
|
|
|