Yeah, that's what I thought as well... :-( So I guess I'll have to check the kernel mode function, and check if it is also implemented in ntdll.dll (like other functions I found). Thanks a lot anyway! :-)
Green Fuze
Posts
-
Get process handle access rights. -
Get process handle access rights.Hey, I know about Access tokens, but it is not what I want. I want to know if the given HANDLE of process has a certain access rights. For instance, SYNCHRONIZE or PROCESS_TERMINATE. Is it possible to do so with Access Token?
-
Get process handle access rights.Hey, Thanks for your answer, but I can't see how it returns the Access rights of the process HANDLE (not the token's access rights).
-
Get process handle access rights.Hey everybody! Is there a way to get access rights out of a process HANDLE ? Thanks! :-)
-
::ReadProcessMemory fails with ERROR_PARTIAL_COPYYes. :-)
-
::ReadProcessMemory fails with ERROR_PARTIAL_COPYHey everybody. I wrote (according to articles I found on the net) the following code, in order to get the command line of another process (it is not the "full code", just until it fails.
HANDLE hproc = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
if(!hproc)
{
printf("OpenProcess() failed: 0x%x", ::GetLastError());
return _T("");
}_NtQueryInformationProcess NtQueryInformationProcess = (_NtQueryInformationProcess)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtQueryInformationProcess");
PROCESS_BASIC_INFORMATION pbi;
DWORD size_written;
NTSTATUS nt = NtQueryInformationProcess(hproc, ProcessBasicInformation, (void*)&pbi, sizeof(PROCESS_BASIC_INFORMATION), &size_written); // get pbi
if(nt)
{
printf("NtQueryInformationProcess() failed: 0x%x", nt);
return _T("");
}PEB* peb = pbi.PebBaseAddress;
ULONG session_id = peb->SessionId;
SIZE_T read_size;
RTL_USER_PROCESS_PARAMETERS* proc_params = NULL;
DWORD old_protection;
if(!::VirtualProtectEx(hproc, peb->ProcessParameters, sizeof(RTL_USER_PROCESS_PARAMETERS*), PAGE_EXECUTE_READWRITE, &old_protection))
{
printf("VirtualProtectEx() failed: 0x%x", ::GetLastError());
return _T("");
}// ************ FAILS HERE !!!! ***************
if(!::ReadProcessMemory(hproc, peb->ProcessParameters, (RTL_USER_PROCESS_PARAMETERS*)proc_params, sizeof(RTL_USER_PROCESS_PARAMETERS*), &read_size))
{
printf("ReadProcessMemory() failed: 0x%x", ::GetLastError());
return _T("");
}if(!::VirtualProtectEx(hproc, peb->ProcessParameters, sizeof(RTL_USER_PROCESS_PARAMETERS*), old_protection, NULL))
{
printf("VirtualProtectEx() failed: 0x%x", ::GetLastError());
return _T("");
}The output is that ReadProcessMemory() fails with ERROR_PARTIAL_COPY. The code works in XP for processes in the same session. Currently I am trying to make it work in windows 7, for a process in the same session. ANY IDEAS any one ???? :confused: Thanks!
-
setlocale() doesn't work!It seems that "american_US" in ::setlocale and 1033 for ::SetThreadLocale() done the trick :-) . It is far too complicated than it should've been! Thanks again! :-)
-
setlocale() doesn't work!Hey, thanks :-) But "English" doesn't return "English (United States)", but generic English. Anyway, I found this GREAT article in codeproject that sort some things out, so I'm sitting on that :-) Windows SetThreadLocale and CRT setlocale[^]
-
setlocale() doesn't work!Hey everybody I have the following code:
wstring curlocale1(::_wsetlocale(LC_ALL, NULL));
printf("+++ current locale: %s", curlocale1.c_str());::_wsetlocale(LC_ALL, L"en_us");
wstring curlocale2(::_wsetlocale(LC_ALL, NULL));
printf("+++ current locale: %s", curlocale2.c_str());and the output is: +++ current locale: C +++ current locale: C I can't understand why my locale does not change, what am I doing wrong? Thanks a lot!
-
Difference between .drv and .sys ???Thanks, it explains many things! :-)
-
LoadLibrary() loads a driver ?!Thanks :-)
-
LoadLibrary() loads a driver ?!Hey everybody, I was wondering... If winspool.drv is a driver (how can I be sure, it is not .sys, but I've been told it is a driver), than how LoadLibrary() loads a driver ?!?!?! does it make any sense ?! Thanks!
-
Difference between .drv and .sys ???Hey Everybody What is the difference (if there is one) between a .DRV driver (like winspool.drv) and other drivers with .sys extension? Thank you!
-
Why C++ doesn't use the parent's class function? (C++ question)Thanks :-) I read about what you said, and I understand why the copy assignment is not being derived, but I can't find anything about the "using A::operator =;". Can I tell c++ explicitly that I want to use the operator at the base class?
-
Why C++ doesn't use the parent's class function? (C++ question)Oh, and the definition of B is: class B : public A_template. :-)
-
Why C++ doesn't use the parent's class function? (C++ question)Hey everybody. Here's a C++ question. I have 2 classes:
template
class A_template
{
public:
... other stuff ...void operator = (T* other){ _obj = other; }
protected:
T* _x;
};
//-----------------------------------------------
class B : public A_template
{
... some functions ...
};Now, the problem is that if I have the following line of code: C* x = CreateC(); B b; b = x; // <--- compiler returns that there is no possible conversion, but it does, in A ! what am I doing wrong?? Thanks a lot !!! :-)
-
How to check if 2 network shares are the same folder.Hey, Thanks for your help! :-) No it doesn't help... Well, I am happy to say that I just found out that Boost library can do that using boost::filesystem::equivalence() function. But my main problem still remains... How to tell that NetFolder1 is NetFolder2's parent? (it is possible to iterate all the shared directories and create a data structure that will hold that data, but when there are many shared folders, it is almost insane!) Thanks Again!!!
-
How to check if 2 network shares are the same folder.Assume the following: In a computer called COMPUTER there is the following folder: c:\folder1\folder2 Now, there are 2 shares: \\COMPUTER\NetFolder2 --> which is c:\folder1\folder2 \\COMPUTER\NetFolder1 --> which is c:\folder1 Now, I can get to through the network to "folder2" in 2 different ways: \\COMPUTER\NetFolder2 \\COMPUTER\NetFolder1\folder2 Is there a way to check that \\COMPUTER\NetFolder2 is the same as \\COMPUTER\NetFolder1\folder2 ??? Thanks! :-)
-
Calling a function directly via VTable.It works! :-) That's so awesome! I'm just asking to get the whole idea of that interface, COM and vtable stuff better. Thanks a lot ! :-)
-
Calling a function directly via VTable.Hey everybody. I am trying to a call a virtual function directly from the VTable. I created a COM component using the visual studio (ATL Simple object).
STDMETHODIMP Ctest_com::print_me(BSTR txt) { OutputDebugString(txt); return S_OK; }
Now, I am trying this use the COM, but calling the function via VTable:// signature of print_me. // STDMETHODCALLTYPE is __stdcall typedef HRESULT (STDMETHODCALLTYPE* ptr_print)(BSTR); int _tmain(int argc, _TCHAR* argv[]) { CoInitialize(NULL); cpp_com_testLib::Itest_com* comobj; HRESULT hr = CoCreateInstance(__uuidof(cpp_com_testLib::test_com), NULL, CLSCTX_INPROC_SERVER, __uuidof(cpp_com_testLib::Itest_com), (void**)&comobj); int* vptr = (int*)(comobj); vptr = (int*)*vptr; // gets a pointer to the VTABLE int* vproc0 = (int*)vptr[0]; // get a point to first function in VTable ... ... ... int* vproc7 = (int*)vptr[7]; // pointer to print_me() ! ptr_print p = (ptr_print)vproc7; // cast to the function pointer. _bstr_t bstr(_T("MY TEXT!")); p(bstr); // <--- happens the problem. comobj->Release(); CoUninitialize(); return 0; }
NOW, here is THE PROBLEM. When I call "p(bstr)" I do get to "print_me()", BUT the parameter "txt" is not passed to the function correctly (I sends a whole different address, so it is a BAD POINTER). ANY IDEAS???? THANKS A LOT IN ADVANCE!