大学から借りてるノートPCにUbuntuStudioインストールしましたkazuです
WindowsXPへの影響を少なくするためにマスターブートレコードにはNTLDRを残したままインストールしました
ところが!!
Linux側からddコマンドを実行する前にUbuntu終了www
仕方がないから再起動後Windows側からUbuntuのブートパラメータブロックをコピーします
その時のメモを…
①CreateFile関数で//./PHYSICALDRIVE?をしてオプーン
②先頭セクタを見てLinuxをインストールしたパーティションのLBAアドレスを探す
③入手したLBAアドレスのセクタをテキトーな名前で保存(私は一応8.3形式に収まる名前にしました)
④(私の場合)WindowsXPがインストールされているCドライブのルートディレクトリにあるboot.iniを書き換えてさっき保存したBPBセクタもこのディレクトリにコピー
これで再起動したらおkでした
すごく汚いですがC++のプログラムを晒しておきます
▼ソースを表示▲ソースを閉じる1 | #include <windows.h> |
2 | #include <stdio.h> |
3 | #include <shlobj.h> |
4 | #pragma pack(push,1) |
5 | typedef struct tagPartitionEntryTable { |
6 | unsigned char bootDescriptor; |
7 | unsigned char firstPartitionSector[3]; |
8 | unsigned char fileSystemDescriptor; |
9 | unsigned char lastPartitionSector[3]; |
10 | unsigned int firstSectorNumbers; |
11 | unsigned int numberOfSectors; |
12 | } PartitionEntryTable; |
13 | #pragma pack(pop) |
14 | void GetDesktopPath(char*); |
15 | void main() |
16 | { |
17 | OVERLAPPED ol={0}; |
18 | HANDLE hDrive = CreateFile("\\\\.\\PHYSICALDRIVE0",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0); |
19 | if(hDrive==INVALID_HANDLE_VALUE)printf("CreateFileError : code = 0x%08x",GetLastError()); |
20 | else { |
21 | unsigned char buf[512]; unsigned long size; int cnt = 446; |
22 | unsigned int firstSectorNumbers[4]; |
23 | PartitionEntryTable* pet; |
24 | ReadFile(hDrive,buf,512,&size,&ol); |
25 | for(int i=0;i<4;i++){ |
26 | pet = (PartitionEntryTable*)&buf[cnt]; |
27 | printf("\nPartition%d ========================\nbootDescriptor : 0x%02x\n",i,pet->bootDescriptor); |
28 | printf("firstPartitionSector : %d\n",(pet->firstPartitionSector[2]<<16)+(pet->firstPartitionSector[1]<<8)+pet->firstPartitionSector[0]); |
29 | printf("fileSystemDescriptor : %d\n",pet->fileSystemDescriptor); |
30 | printf("lastPartitionSector : %d\n",(pet->lastPartitionSector[2]<<16)+(pet->lastPartitionSector[1]<<8)+pet->lastPartitionSector[0]); |
31 | printf("firstSectorNumbers : %d\n",pet->firstSectorNumbers); |
32 | printf("numberOfSectors : %d\n\n",pet->numberOfSectors); |
33 | cnt+=16; |
34 | firstSectorNumbers[i]=pet->firstSectorNumbers; |
35 | } |
36 | // 保存ファイルパスの生成 |
37 | int numBPB; |
38 | char desktop[260],temp[260]; |
39 | printf("取得したいBPB番号を入力してください(取得しない場合は-1を入力) : "); |
40 | scanf("%d",&numBPB); |
41 | if((numBPB>=0)&&(numBPB<4)){ |
42 | GetDesktopPath(temp); |
43 | sprintf(desktop,"%s\\Ubuntu.br",temp,numBPB); |
44 | // 保存ファイル生成 |
45 | ol.Offset = firstSectorNumbers[numBPB] << 9; |
46 | ol.OffsetHigh = firstSectorNumbers[numBPB] >> (32-9); |
47 | ReadFile(hDrive,buf,512,&size,&ol); |
48 | FILE* fp = fopen(desktop,"wb"); |
49 | if(fp==NULL)printf("fopenエラー"); |
50 | else { |
51 | fwrite(buf,sizeof(char),512,fp); |
52 | fclose(fp); |
53 | } |
54 | } |
55 | CloseHandle(hDrive); |
56 | } |
57 | } |
58 | void GetDesktopPath(char *path) |
59 | { |
60 | LPITEMIDLIST pidl; |
61 | SHGetSpecialFolderLocation(NULL,CSIDL_DESKTOP,&pidl); |
62 | SHGetPathFromIDList(pidl,path); |
63 | CoTaskMemFree(pidl); |
64 | } |
ちなみに環境は Windows XP Professional SP3 / Borland C++ Compiler 5.5 です
余談はここまでにして本題の計算フォームです
非同期シリアル通信(8bit/Asynchronous/Non Parity/Stopbit=1)
例の通り計算結果のご利用は自己責任でお願いしますね
今回もPIC16F687のデータシートを参照しました
他のPICでは計算式が異なる場合があるかもしれません
ビット当たりのずれが5%を超えるとErrorを返すようにしてあります
やっと地霊殿で新キャラに出会えたww
この記事を書いている途中にループ再生していた音楽:Border of extacy
次の記事を書くときに聞く予定の音楽:ひれ伏せ愚民どもっ!
いや…そんな趣味は無いよor2or2or2or2or2or2or2or2or2or2
だって僕も彼↓と同じ紳士だもんww
追記
①ソースコード中に字下げ用として使った はIEだと□になってしまうようです
②今回書いた計算フォームのJavascriptはIEだと正常に動作しないようです(過去の記事「計算フォーム」と名前空間が同じ!?)
0 件のコメント:
コメントを投稿