Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
G

Green Fuze

@Green Fuze
About
Posts
293
Topics
123
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Get process handle access rights.
    G Green Fuze

    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! :-)

    ATL / WTL / STL question

  • Get process handle access rights.
    G Green Fuze

    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?

    ATL / WTL / STL question

  • Get process handle access rights.
    G Green Fuze

    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).

    ATL / WTL / STL question

  • Get process handle access rights.
    G Green Fuze

    Hey everybody! Is there a way to get access rights out of a process HANDLE ? Thanks! :-)

    ATL / WTL / STL question

  • ::ReadProcessMemory fails with ERROR_PARTIAL_COPY
    G Green Fuze

    Yes. :-)

    ATL / WTL / STL help question

  • ::ReadProcessMemory fails with ERROR_PARTIAL_COPY
    G Green Fuze

    Hey 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!

    ATL / WTL / STL help question

  • setlocale() doesn't work!
    G Green Fuze

    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! :-)

    C / C++ / MFC question

  • setlocale() doesn't work!
    G Green Fuze

    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[^]

    C / C++ / MFC question

  • setlocale() doesn't work!
    G Green Fuze

    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!

    C / C++ / MFC question

  • Difference between .drv and .sys ???
    G Green Fuze

    Thanks, it explains many things! :-)

    Hardware & Devices question

  • LoadLibrary() loads a driver ?!
    G Green Fuze

    Thanks :-)

    C / C++ / MFC question

  • LoadLibrary() loads a driver ?!
    G Green Fuze

    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!

    C / C++ / MFC question

  • Difference between .drv and .sys ???
    G Green Fuze

    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!

    Hardware & Devices question

  • Why C++ doesn't use the parent's class function? (C++ question)
    G Green Fuze

    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?

    C / C++ / MFC question c++ help

  • Why C++ doesn't use the parent's class function? (C++ question)
    G Green Fuze

    Oh, and the definition of B is: class B : public A_template. :-)

    C / C++ / MFC question c++ help

  • Why C++ doesn't use the parent's class function? (C++ question)
    G Green Fuze

    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 !!! :-)

    C / C++ / MFC question c++ help

  • How to check if 2 network shares are the same folder.
    G Green Fuze

    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!!!

    C / C++ / MFC sysadmin tutorial question

  • How to check if 2 network shares are the same folder.
    G Green Fuze

    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! :-)

    C / C++ / MFC sysadmin tutorial question

  • Calling a function directly via VTable.
    G Green Fuze

    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 ! :-)

    C / C++ / MFC csharp c++ visual-studio com help

  • Calling a function directly via VTable.
    G Green Fuze

    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!

    C / C++ / MFC csharp c++ visual-studio com help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups