|
|
If you're looking for someone to write your code for you, that's not going to happen here.
|
|
|
|
|
Forget the code, I'd be more impressed with someone that could understand just what it is he's saying. It's like a condensed version of abbreviated shorthand.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
It's so obtuse that, were in a bad mood, I'd start to flag every post as trolling.
|
|
|
|
|
|
Hello
I'm looking for How to deny usb(cd, floppy, portable hard drive, blu ray...) read and write based on vs2019.
File, Code, Class, anyone is ok.
Development on Windows Drive Kit or just VS2019, contact on filter driver i do not know which one suitable method on me.
plz Help me.....
|
|
|
|
|
Are you wanting this "denial" to happen only while your program is running, or all the time (service, or maybe something running in ring 1 or 2)?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I really really appreciated your opinion.
I want to deny media device when running my program.
Course of, no one should be able to kill my program.
Making my program unkillable is also a problem, but I want the media devices to be inaccessible when my program is running.
I would wait your answer once again.
modified 27-Jul-20 23:00pm.
|
|
|
|
|
There's already policies in place that take care of that. You don't have to write a single line of code.
Google for "group policy disable usb write".
|
|
|
|
|
Thank you for answer.
However, I think that way, if I log in as an administrator, it's all through.
I have to program to prevent all situations.
Please tell me, if you have any other opinion.
Thank you.
|
|
|
|
|
If you log in as admin, no it isn't all through. It's a machine policy.
As an admin, if you write your app as a service, I can just kill the process.
The ONLY way you're going to do this with code is writing a device driver you inject into the USB chain. Do not ask me how to do that. I have no idea.
|
|
|
|
|
It was a big hint to me.
I don't know if I can....
Thank you.
|
|
|
|
|
I have the following code:
CRegKey reg;
CString sData;
CByteArray arrByte;
ULONG nLength = 0;
if (ERROR_SUCCESS == reg.Open(HKEY_CURRENT_USER, sKeyName, KEY_READ) &&
ERROR_SUCCESS == reg.QueryBinaryValue(sValueName, arrByte.GetData(), &nLength))
{
sData = CString((LPCTSTR)arrByte.GetData(), arrByte.GetSize());
}
the code is running on sData = ...
nLength has 10 value, sData is empty, arrByte has 0 size ... what I am missing here ? Of course, in that registry location I have data ...
|
|
|
|
|
|
Thank you.
modified 26-Jul-20 2:21am.
|
|
|
|
|
_Flaviu wrote: sData = CString((LPCTSTR)arrByte.GetData(), arrByte.GetSize());
Note that conversion from byte array to CString may give you an unexpected result in some cases, also when compiling as MBCS.
For instance when the byte array contains one or more zero bytes. In such a case you will get a truncated string!
|
|
|
|
|
This is the full warning in question:
warning C6385: Reading invalid data from 'lines': the readable size is '(unsigned int)*4+4' bytes, but '8' bytes may be read.
I just (finally) converted a VS2013 project to VS2019, and as part of the cleanup I've been running the code analysis to help me spot issues. Below is a minimalist version of an oddity I found.
So here's the case that started the journey. You can assume m_iNumLines is a UINT greater than 0; checking for this and other error conditions (e.g. that the pointer is not NULL) did not eliminate the warning. Simplified for clarity, this is verbatim code that triggered the warning:
void CTestClass::SetText()
{
CString* lines = new CString[m_iNumLines];
for (UINT i = 0; i < m_iNumLines; i++)
{
lines[i] = "TestString";
}
delete[] lines;
}
I first tried covering every last (even absurd) error case to try and eliminate the warning, but changing lines[i] to *(lines + i) did it:
void CTestClass::SetText()
{
CString* lines = new CString[m_iNumLines];
for (UINT i = 0; i < m_iNumLines; i++)
{
*(lines + i) = "TestString";
}
delete[] lines;
}
I'm not sure what about handling of CStrings & pointers would make that an improvement. But here's what really baked my noodle. If I leave both lines in - even with the code that triggered thee warning first - I no longer get the warning:
void CTestClass::SetText()
{
CString* lines = new CString[m_iNumLines];
for (UINT i = 0; i < m_iNumLines; i++)
{
lines[i] = "TestString";
*(lines + i) = "TestString2";
}
delete[] lines;
}
I also get no warning if I swapped the order (thinking maybe optimization - even in a debug build - made the first line do nothing).
In searching I found others getting this warning also when using CStrings, but in situations much more convoluted than this, and I didn't see how it explained my case. Also I get the same results when using std::string, for what it's worth.
Look at me still talking when there's science to do
When I look out there it makes me glad I'm not you
|
|
|
|
|
I think the issue is that the variable lines is a pointer to an array of CString objects, it is not an array of pointers.
After further tests (non-MFC) I cannot get it to fail, or produce any error messages.
modified 24-Jul-20 4:58am.
|
|
|
|
|
FWIW, Visual Studio's C++ analysis is so bad, I keep it turned off. (Yes, it can find errors, but the number of false positives makes it pretty much worthless.)
|
|
|
|
|
not sure where to post this but i have a number of old projects that build pretty well with visual studio 2003 and 2005
but i dont want to jump around between two versions, i want to use the latest version of VS for both projects
my real problem is that VS2019 platform toolset option doesnt have V71 or V80
anyway i can point it to the actual versions i have already installed to build the projects?
thanks
|
|
|
|
|
hmd-omani wrote: my real problem is that VS2019 platform toolset option doesnt have V71 or V80
Then you will have to rebuild your old projects/solutions using the latest toolset!
|
|
|
|
|
is there no way to manually add those toolsets?
|
|
|
|
|
|
You should be able to select whatever toolsets are installed on your system, from the Project properties of Visual Studio 2019. However, it is advisable to use the latest one which will contain all the most up to date fixes and enhancements, and be fully compatible with the latest version of Windows.
|
|
|
|
|
it shows v90 and if i try to build using that it will say you need to install vc2008
so i guess it doesnt have to do with what you have installed on your system cuz if that was true than v71 & v80 would show up
|
|
|
|