비트연산기

HardCoding/기타 2015. 5. 12. 20:42

485통신을 쓰는 우리 회사 장비를 디버깅 할때 늘 고생해서

오늘도 개삽질중에 설마 이런게 있겠어?? 이런 생각으로 멍때리며 구글링하다가

내가 딱! 원하는 유틸리티를 찾았음.


완전 환상적이야~~~

비트분석기.zip






원문 : http://www.hongikcom.com/15



Posted by 싸이on
,

디버그로 브레이크 포인트 잡아서 디버깅을 할때...

 

가끔...

"중단점이 현재 적중되지 않습니다. 소스코드가 원래 버전과 다릅니다."

라고 나오는 경우 브레이크 포인트가 잡히질 않는다.

 

솔루션 정리나 솔루선 다시 빌드 등을 해봐도 동일한 현상이 나타난다.

 

열심히 구글링해서 찾은 해결방법.

 

1. 도구>옵션>디버깅에서 "소스 파일이 원래 버전과 정확하게 일치해야 함"을 해제한다.

 - 이 방법을 사용하면 "중단점이..." 하는 메세지는 나오지 않으나 역시 브레이크 포인트는 안잡힌다.

 

2. 브레이크 포인트를 거는 소스파일과 헤더파일의 인코딩 형식을 Unicode(UTF-8 With signature) - Codepage 65001로 설정한다.

 - 기존 설정은 Korean-Codepage 949로 되있음. VS2008 상단 메뉴에서 파일>고급저장옵션에서 설정.

 

결론...

 

해결방법 2로 완전 클리어하게 해결.

브레이크 포인트를 걸 수 있어서 열심히 디버깅중...

Posted by 싸이on
,

iptime 공유기에서 설정해놓은 ddns로 공유기의 유동ip를 가져오는 방법을 찾던 중에

 

DnsQuery() 라는 함수를 통해 가져올 수 있을것 같다는 판단하에 삽질 실행...

 

 DNS_STATUS WINAPI DnsQuery(
  _In_         PCTSTR lpstrName,
  _In_         WORD wType,
  _In_         DWORD Options,
  _Inout_opt_  PVOID pExtra,
  _Out_opt_    PDNS_RECORD *ppQueryResultsSet,
  _Out_opt_    PVOID *pReserved
  );

 

 Parameters


 lpstrName [in]
 A pointer to a string that represents the DNS name to query.

 wType [in]
 A value that represents the Resource Record (RR) DNS Record Type that is queried. wType determines the format of data pointed to by ppQueryResultsSet. For example, if the value of wType is DNS_TYPE_A, the format of data pointed to by ppQueryResultsSet is DNS_A_DATA.

 Options [in]
 A value that contains a bitmap of DNS Query Options to use in the DNS query. Options can be combined and all options override DNS_QUERY_STANDARD.

 pExtra [in, out, optional]
 This parameter is reserved for future use and must be set to NULL.

 ppQueryResultsSet [out, optional]
 Optional. A pointer to a pointer that points to the list of RRs that comprise the response. For more information, see the Remarks section.

 pReserved [out, optional]
 This parameter is reserved for future use and must be set to NULL.

 

 Return value
 Returns success confirmation upon successful completion. Otherwise, returns the appropriate DNS-specific error code as defined in Winerror.h.

 

프로젝트 추가

 include <WinDNS.h>
 include Ws2_32.lib Dnsapi.lib

 

코드

 // Calling function DnsQuery to query Host or PTR records  
 status = DnsQuery(     pOwnerName,                 //Pointer to OwnerName. 
                                 DNS_TYPE_A,                //Type of the record to be queried.
                                 DNS_QUERY_STANDARD,//Standard query.
                                 pSrvList,                        //Contains DNS server IP address.
                                 &pDnsRecord,                //Resource record that contains the esponse.
                                  NULL);                          //Reserved for future use.

 if (status) // DnsQuery Fail
 {
      if(wType == DNS_TYPE_A)  
      {
       //   printf("Failed to query the host record for %s and the error is %d \n", pOwnerName, status);
           AtlMessageBox(m_hWnd,L"DNS_TYPE_A Fail",L"Fail 1",MB_OK | MB_ICONSTOP);
       }
       else
      {
           //   printf("Failed to query the PTR record and the error is %d \n", status);
           AtlMessageBox(m_hWnd,L"DNS_TYPE Fail",L"Fail 2",MB_OK | MB_ICONSTOP);
      }
 }
 else
 {
      if(wType == DNS_TYPE_A) // Dns Name -> IP Address
      {
           //convert the Internet network address into a string
           //in Internet standard dotted format.
           ipaddr.S_un.S_addr = (pDnsRecord->Data.A.IpAddress);
           //printf("The IP address of the host %s is %s \n", pOwnerName,inet_ntoa(ipaddr));
           char stAddr[MAX_PATH]={0,};
           strcpy(stAddr, inet_ntoa(ipaddr)); // inet_ntoa(ipaddr) -> Ansi로 리턴

int nLen = 0;

BSTR buf = NULL;               // 유니코드 문자열 저장 버퍼
nLen = MultiByteToWideChar(CP_ACP, 0, stAddr, strlen(stAddr), NULL, NULL); // 변환된 후의 문자열의 길이를 확인
buf = SysAllocStringLen(NULL, nLen);          // 필요한 길이만큼 메모리 할당
MultiByteToWideChar(CP_ACP, 0, stAddr, strlen(stAddr), buf, nLen);   // 문자 변환
CString  cStrAddress = (LPCWSTR)buf;    // BSTR to CString

_ip_Temp = htonl(inet_addr((CStringA)cStrAddress)); // CString to const char*(DWORD)
  
/*
//CString -> const char*
CString str1 = _T("aaa");
const char* str2;
str2 = (CStringA) str1;

//const char* -> CString
const char* str1 = "aaa";
CString str2;
str2 = (CString)str1; 
*/
//////////////////////////////////////////////////////////////////////////

           // Free memory allocated for DNS records. 
           DnsRecordListFree(pDnsRecord, freetype);
  }
  else
  {
           //printf("The host name is %s  \n",(pDnsRecord->Data.PTR.pNameHost));

CString cstrTemp;
cstrTemp.Format(L"The host name is %s", (pDnsRecord->Data.PTR.pNameHost));
// Free memory allocated for DNS records. 
DnsRecordListFree(pDnsRecord, freetype);

   }

}
LocalFree(pSrvList);

 

테스트 결과...

 

는 나중에... ㄷㄷㄷ

 

 

Posted by 싸이on
,