الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

diffrence between CreatenamedPipe CreatePipe

مغلق
بدأه seco في 19 فبراير 2005 · 8 رد · 726 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

ما الفرق بين CreateNamedPipe و CreatePipe وكيف اجعل اتصال بين جهازين عن طريق client and serverPipe

شكرا لكم

Nothing Beat the Human Brain

موبايل 020104927122

#2

لإنشاء pipe أو أنبوب معلومات جديد خاص بي

أستخدم الدالة CreateNamedPipe

لنفرض أننا أنشئنا الأنبوب

"\\pipe\\hello"

لاحظ هذا الكود , عبارة عن برنامجين عميل وخادم يستخدمان الأنبوب pipe\hello

العميل :

الأنبوب المستخدم pipe\hello البيانات المرسلة hello, world

#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "hello.h" 

void main()
{
    RPC_STATUS status;
    unsigned char * pszUuid             = NULL;
    unsigned char * pszProtocolSequence = "ncacn_np";
    unsigned char * pszNetworkAddress   = NULL;
    unsigned char * pszEndpoint    = "\\pipe\\hello";
    unsigned char * pszOptions          = NULL;
    unsigned char * pszStringBinding    = NULL;
    unsigned char * pszString      = "hello, world";
    unsigned long ulCode;

    status = RpcStringBindingCompose(pszUuid,
                                     pszProtocolSequence,
                                     pszNetworkAddress,
                                     pszEndpoint,
                                     pszOptions,
                                     &pszStringBinding);
    if (status) {
        exit(status);
    }
    status = RpcBindingFromStringBinding(pszStringBinding,
                                         &hello_IfHandle);

    if (status) {
        exit(status);
    }


    RpcTryExcept {
        HelloProc(pszString);
        Shutdown();
    }
    RpcExcept(1) {
        ulCode = RpcExceptionCode();
        printf("Runtime reported exception 0x%lx = %ld\n", ulCode, ulCode);
    }
    RpcEndExcept

    status = RpcStringFree(&pszStringBinding); 

    if (status) {
        exit(status);
    }

    status = RpcBindingFree(&hello_IfHandle);

    if (status) {
        exit(status);
    }

    exit(0);

}  // end main()

برنامج الخادم:

#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "hello.h"

void main()
{
    RPC_STATUS status;
    unsigned char * pszProtocolSequence = "ncacn_np";
    unsigned char * pszSecurity     = NULL; /*Security not implemented */
    unsigned char * pszEndpoint    = "\\pipe\\hello";
    unsigned int    cMinCalls           = 1;
    unsigned int    cMaxCalls           = 20;
    unsigned int    fDontWait           = FALSE;

    status = RpcServerUseProtseqEp(pszProtocolSequence,
                                   cMaxCalls,
                                   pszEndpoint,
                                   pszSecurity); 

    if (status) {
        exit(status);
    }

    status = RpcServerRegisterIf(hello_v1_0_s_ifspec,  
                                 NULL,   
                                 NULL); 

    if (status) {
        exit(status);
    }

    status = RpcServerListen(cMinCalls,
                             cMaxCalls,
                             fDontWait);

    if (status) {
        exit(status);
    }

 }  // end main()

-

أما عن الدالة CreatePipe

تستخدم لإرجاع مقبض آخر عمليتين قرائة وكتابة ( مقبض pipe )

-

http://www.jaascois.com

*************************************************

مجموعة مواضيع - إحتراف البرمجة -

ّ~~~~~~~~~~~~~~~~~~~~~~

البرمجة المتقدمة & الهندسة العكسية & برمجة وأمن الأنظمة

/index.php?showtopic=45002

آخر المواضيع :

+- تحليل جرائم الكمبيوتر -+

أنظمة اليونكس(Solaris,HP, AIX,SCO)وانواع المعالجات

ثغرة SMS لأجهزة الجوال Siemens 3568i !

أخطاء وثغرات البرامج العربية !!!

سلسلة مواضيع - أمن وحماية مواقع الويب -

E البرمجة المتقدمة X للملفات التنفيذية E

سلسلة مواضيع ثغرات الأنظمة وإختراق الأجهزة

**************************************************

<span style='font-size:14pt;line-height:100%'>الإرادة تحـــقق السيـــادة</span>

**************************************************

#3

شكرا با جاس على هذه المعلومات

جزاك الله خيرا .

Nothing Beat the Human Brain

موبايل 020104927122

#4

كلام جميل لكن ماهو ال Pipe هنا أصلا ؟

"\\pipe\\hello"

عموما هذا كود آخر كنت أريد إرفاقه , لكني لم أعرف ماهية ال Pipe الذي سنتصل به !

// Server.cpp

#include <windows.h>
#include <stdio.h>

void main(void)
{
    HANDLE PipeHandle;
    DWORD BytesRead;
    CHAR buffer[256];

    if ((PipeHandle = CreateNamedPipe("\\\\.\\Pipe\\Jim",
        PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 1,e
        0, 0, 1000, NULL)) == INVALID_HANDLE_VALUE)
    {
        printf("CreateNamedPipe failed with error %d\n",
            GetLastError());
        return;
    }

    printf("Server is now running\n");

    if (ConnectNamedPipe(PipeHandle, NULL) == 0)
    {
        printf("ConnectNamedPipe failed with error %d\n",
            GetLastError());
        CloseHandle(PipeHandle);
        return;
    }

    if (ReadFile(PipeHandle, buffer, sizeof(buffer),
        &BytesRead,  NULL) <= 0)
    {
        printf("ReadFile failed with error %d\n", GetLastError());
        CloseHandle(PipeHandle);
        return;
    }

    printf("%.*s\n", BytesRead, buffer);

    if (DisconnectNamedPipe(PipeHandle) == 0)
    {
        printf("DisconnectNamedPipe failed with error %d\n",
            GetLastError());
        return;
    }

    CloseHandle(PipeHandle);
}

للكلاينت :

// Client.cpp

#include <windows.h>
#include <stdio.h>

#define PIPE_NAME "\\\\.\\Pipe\\jim"

void main(void)
{
    HANDLE PipeHandle;
    DWORD BytesWritten;

    if (WaitNamedPipe(PIPE_NAME, NMPWAIT_WAIT_FOREVER) == 0)
    {
        printf("WaitNamedPipe failed with error %d\n",
            GetLastError());
        return;
    }

    // Create the named pipe file handle
    if ((PipeHandle = CreateFile(PIPE_NAME,
        GENERIC_READ | GENERIC_WRITE, 0,
        (LPSECURITY_ATTRIBUTES) NULL, OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL,
        (HANDLE) NULL)) == INVALID_HANDLE_VALUE)
    {
        printf("CreateFile failed with error %d\n", GetLastError());
        return;
    }

    if (WriteFile(PipeHandle, "This is a test", 14, &BytesWritten, 
        NULL) == 0)
    {
        printf("WriteFile failed with error %d\n", GetLastError());
        CloseHandle(PipeHandle);
        return;
    }

    printf("Wrote %d bytes", BytesWritten);

    CloseHandle(PipeHandle);
}

ماذا يمكن أن يكون : "\\\\.\\Pipe\\jim"

وأين يتم تثبيته !! وعلى أي أساس , أسئلة كثيرة لاأعرف لها إجابة حاليا .

banner_60_468.gif

NOTHING IS IMPOSSIBLE

#5

Named pipes and mailslots are programming APIs that Microsoft put them in windows like win32api

mailslots: like pipes put for email send and receive through CreateMailSlot()

you can imagin named pipes and mailslots are channels that transfer data

but jaas use Rpc (remote procedure call) to send data and it's a kind of networking API also.

==== Good Luck====

#6
اقتباس
ماذا يمكن أن يكون : "\\\\.\\Pipe\\jim"

this is an alias for yor computer

#7

تشكر جزيلا يا macnux :

اقتباس
ماذا يمكن أن يكون : "\\\\.\\Pipe\\jim"

this is an alias for yor computer

هذا ماكنت أريد فعلا .

==========

بالنسبة لكود RpC الخاص ب Jaas لم أجرب الكود حتى الآن , لكن أظن أنه يخرج بالمنفذ 135 أو 139 . لدي بريمج snifing هنا سأعرف به المنفذ , يمكن إستخدام firewall أيضا لذلك .

عموما سأجرب الكود ولنر ماسيحدث .

banner_60_468.gif

NOTHING IS IMPOSSIBLE

#8

السلام عليكم

لمنه يريد فهم ماهو Named pipe عليه زيارة الموقع التالى

http://www.sysinternals.com/ntw2k/info/tips.shtml

هناك شرح وافى معى مثال ممتاز جداً, وعلى فكره موقع

http://www.sysinternals.com/

كنحصص فى شرح خصائص نظام الوندوز وفيه برامج وشرح لن تجدها فى اى موقع اخر .

والسلام

لا إله إلا الله محمد رسول الله

busbar : يجب ان تدرك انه هناك حد ادنى للمعرفة المطلوبة قبل البدء في عمل أي شئ.

#9

بارك الله فيك يا احمد

شكرا لك.

Nothing Beat the Human Brain

موبايل 020104927122

هذا الموضوع مغلق.

مواضيع مشابهة